- Home /
Question about Update vs FixedUpdate
I'm creating a player controller for a 2d platformer without using the CharacterController component. All of my collisions are detected using raycasts.
My question is: Should I do all of my collisions+movement in a FixedUpdate call or in Update with movement as a factor of Time.deltaTime ?
I'm not sure if there is a significant difference, but I've noticed strange behavior running in browser on slower machines while currently using FixedUpdate. Thanks for any input.
Answer by dannyskim · Apr 26, 2012 at 08:14 PM
FixedUpdate should really only be used when you're dealing with some sort of physics interaction. FixedUpdate is also at a (obviously) fixed frame step, and a maximum allowed time step, which is specifically for normalizing physics across varying machines.
You may want to consider raycasting and controlling the raycasts in update, and any physics / rigidbody movement in FixedUpdate.
Another note: if you run in FixedUpdate, don't use Time.deltaTime, use Time.fixedDeltaTime: http://unity3d.com/support/documentation/ScriptReference/Time-fixedDeltaTime.html . You could definitely get strange behaviour if you're not using the right delta time.
@NOAA_Julien: in FixedUpdate, Time.deltaTime returns Time.fixedDeltaTime.
Thanks, this is exactly the answer I was looking for. I wasn't sure if FixedUpdate was intended for all Physics interactions (such as Physics.raycast)
Your answer
Follow this Question
Related Questions
Update/FixedUpdate motion stutter (Note: This is NOT a novice deltaTime question) 16 Answers
Checkibg Rigidbody2d and component problems 0 Answers
Fixedupdate rate stays at 90 instead of 60 1 Answer
Why is OnGUI called significantly more than Update and FixedUpdate? 4 Answers
So what's the deal with FixedUpdate? 2 Answers