Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Bug? And any way to do something for 5 seconds when shift is held?

$
0
0
I need to setup a power up system so on shift down the rigid-body on the player will be disabled. Here is the code I have so far. The only problem with this code is when you hit shift in the game.... Frozen freezes up every time. void Update () { PowerupTimer = Time.realtimeSinceStartup; PowerupTimer2 = Time.realtimeSinceStartup + 5; if(Input.GetKeyDown(KeyCode.LeftShift) & PowerupUsed == false) { NoclipPowerup(); } } void InstantiatePlatforms() { while(NumberOfPlatforms > 0) { RandNum = Random.Range(0,PlatformList.Count); //Generates a random number from zero to the total amount of things in our list Instantiate(Platform, PlatformList[RandNum].position, Quaternion.identity); PlatformList.RemoveAt(RandNum); //Removes the transform contained at the index we picked at random. You don't want to reuse a spot, since that could put a platform on top of a platform. NumberOfPlatforms = NumberOfPlatforms - 1; } } void NoclipPowerup() { while(PowerupTimer < PowerupTimer2) { Debug.Log("The Powerup works"); } } Any ideas on the powerup and/or how to fix the crash?

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>