Exactly what Tekrel says above. But also:
-
Always use FixedUpdate() when dealing with physics, otherwise you will get inconsistent results
-
Don’t use
Input.GetKeyDown()
orInput.GetKeyUp()
. Just useInput.GetKey()
and either set the velocity to zero or nonzero based on what you get back fromInput.GetKey()
-
Always use code tags when posting code to this forum.
How to use code tags: Using code tags properly