- Home /
What is a Fixed Update?
I asked a question a while ago:
http://answers.unity3d.com/questions/13074/player-shakes-on-movement/13163#13163
And the answer I got was to put my camera movements in a fixed update. How would I do that. And does someone have a better answer for my previous question?
Answer by Jaap Kreijkamp · Jun 23, 2010 at 01:33 AM
Update is called every frame that's drawed. FixedUpdate is called at fixed intervals (you can define the interval in Edit -> Project Settings -> Time -> Fixed Timestep). It's used internally for Physics and a good place for putting things that should be framerate independent. For example if you made a simple counter and put it in Update it will count slower when framerate drops, not when put in FixedUpdate.
FixedUpdate is pretty much just for physics; use Time.deltaTime in Update to make things framerate-independent. There are several drawbacks to using FixedUpdate for anything else: if you decide you need a different physics framerate, then your code ti$$anonymous$$g changes even though it's not related to physics (trust me, I've been there). Also, Unity tries to make FixedUpdate run at 50 fps or whatever even in low fps situations, which is generally the opposite of what you want. So most of the time you should keep FixedUpdate functions lightweight and only for physics-related code.
Eric, I want to run a deter$$anonymous$$istic simulation where every time I run it, I get the exact same results, independent of framerate. This doesn't involve Unity physics, just numbers in an economy, non-rigidbody movement, etc.
Will adjusting solely with Time.deltaTime make my results deter$$anonymous$$istic? If I'm doing any kind of acceleration/compounding of a value, the result will change depending on the framerate, won't it?
Is FixedUpdate inappropriate to use in such a situation? I should set up a framerate-independent update loop ins$$anonymous$$d?
I found out the problem. It is the damping on my smooth follow script. But if I turn the damping off I get a lot less natural effect. Solution??
Can I also put a random range for the fixedUpdate() to execute?
Answer by MatheusNani · Jan 11, 2018 at 03:54 AM
Follow Unity Documentation > Update and FixedUpdate