Here’s the code that makes my character jump. When the jump button is released, the character is supposed to jump. In the docs, it says to put “GetButtonUp” in the Update function and to put anything that deals with physics in the FixedUpdate function. The problem is I have both in my little bit of code.
// jump code
if (Input.GetButtonUp ("Jump"))
rigidbody.velocity = rigidbody.velocity + Vector3.up * jumpAmount;
It should be in Update, because GetButtonUp only returns true for the single frame that it happens in, and FixedUpdate doesn’t necessarily run every frame, so it can and does miss ButtonDown/Up events.
Just to clarify a bit more, if you’re applying forces continuously that should be in FixedUpdate, but with a one-off application of force, it doesn’t really matter if it’s in Update or FixedUpdate.
The FixedUpdate is framerate-independent, you can modify the variable you wanna update in the way of framerate-independent in Update by multiply the variable by Time.deltaTime.