O'Reilly logo

Unity 3 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

FixedUpdate

FixedUpdate is called for every fixed framerate frame, if MonoBehavior is enabled.

FixedUpdate should be used instead of Update when dealing with Rigidbody. For example, when adding a force to a rigidbody, you have to apply the force for every fixed frame inside FixedUpdate instead of every frame inside Update, because the physics simulation is carried out in discrete timesteps. The FixedUpdate function is called immediately before each step.

Example

// Apply an upward force to the rigidbody every frame
function FixedUpdate () {
  rigidBody.AddForce(Vector3.up);
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required