I’m trying to increase the speed of my character by an amount as long as space (or touch) is held. The following does not seem to work. I have to spam the space bar to see any speed increase.
if(Input.GetButtonDown("Jump")){ speed += speedGain; }
Any help would be greatly appreciated, thank you!
if (Input.GetButton("Jump")) { speed += speedGain * Time.deltaTime; }
–Eric
Multiply speedGain by Time.deltaTime, too.
http://unity3d.com/support/documentation/ScriptReference/index.Keeping_Track_of_Time.html
Edit: The result will be what Eric gave you.
speed = speed + amount; or speed ++; // +1
Ah, it was checking if i pushed it down on that frame. And I always forget deltaTime… I’m a doofus, thank you guys!
That won’t work, because it will be framerate-dependent.
Sorry, i didn’t read his question… and only looked at his script.