Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Player Input and Cameras Move the Player with Animation

Ranvir Sahota
Ranvir Sahota
9,844 Points

FixedUpdate vs Update

I'm struggling to understand the difference between FixedUpdate and Update. I'm just lost and really need an answer for this. (I haven't linked all sources just key ones that got me to this point)

I looked at this video but this was left wondering why would I use fixedUpdate? If fixed update can not be called between frame how will the physics inside be executed. https://unity3d.com/learn/tutorials/topics/scripting/update-and-fixedupdate

I then read the following articles http://answers.unity3d.com/questions/10993/whats-the-difference-between-update-and-fixedupdat.html http://gamedev.stackexchange.com/questions/73713/update-vs-fixedupdate-in-unity

Felt like I was getting closer to understanding it then I read this one and everything went mush again http://gamedev.stackexchange.com/questions/93850/difference-between-update-method-and-fixedupdate-in-unity

Can someone please help me understand this its giving me a headache. I think it might be best for someone to explain this from scratch What is FixedUpdate Differences Between FixedUpdate and Update Why use fixed Update and Update Can fixedUpdate be used in place of update or the other way around? Through my research I saw posts saying that FixedUpdate may not be called between frames but then how will physics be calculated if not being called? I also discovered that FixedUpdaate calls vary depending on Update but how will more call on FixedUpdate help Update speed?

I understand this may be hard to answer but I truly require an answer as I'm at a complete loss and this doesn't happen to me often especially for something used frequently and vital as FixedUpdate so the sources state.

Thanks in advance

2 Answers

Update is called every frame, but isn't good for doing physics performance inside, but is good at doing almost anything else that must be called every frame.

FIxedUpdate is great for physics.

I think the Unity3D Documentation for FixedUpdate is great to read and this Unity3D question as well.

The documentation says for Update:

Update is called every frame, if the MonoBehaviour is enabled.

Update is the most commonly used function to implement any kind of game behaviour.

The documentation says for FixedUpdate:

This function is called every fixed framerate frame, if the MonoBehaviour 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 every fixed frame inside FixedUpdate instead of every frame inside Update.

I hope this helps :bowtie:

:dizzy: ~Alex :dizzy:

Ranvir Sahota
Ranvir Sahota
9,844 Points

Why is Update not good when dealing with Rigibody but FixedUpdate is good for dealing with it?

geoffrey
geoffrey
28,736 Points

Hi Ranvir Sahota During the video Nick states this:

FixedUpdate is used to create smooth animation for objects that rely on physics, like the frog character moving around the screen. Calculating the many variables involved in a physics simulation, like a ball bouncing off of a wall, while also being pulled down to the ground by gravity, can require a lot of computing power. The Update method runs at each frame, so forcing a computer to try to keep up with the complex calculations every single frame could slow your game down and ruin the experience for the player. The FixedUpdate method doesn't run as often, so it can still keep up with the computational complexity of an object's animation, without significantly slowing down gameplay. Just remember that any time you deal with physics, you probably need to use FixedUpdate.

So that's the reason. Hope It helps.