Physics help needed

Hello All,

I am a unity game developer from last one year,but cannot find why unity always tell us to to all the physics related things in FixedUpdate rather then in Update or any other function.???

Even i have some idea because i am using unity,but still i dont think i have the exact answer of this question or number of benefits of this.

if any one know the reasons for this,please do reply or provide me a link where i can read this thing.

Thanks in Advance!
Niki.j

Physics runs on a fixed time step, which is what FixedUpdate correlates to, and is 50 times per second by default. Update is every frame. The two don’t generally match.

–Eric

Hello Eric

Thank you so much for this conformation…
Eric do you have any link to read more about the relation between fixed update() and physics???

if yes then please let me know,i want to understand the things more deeply so that i can improve my coding standard while playing with physics…

Thanks Regards:
Niki.j

I can tell you that there is a FixedUpdate() because of the physics solver that is used. I think unity used PhysX or something like that. The reason there is a fixed time step is because the solver implemented requires each physics time step to be the same(fixed). There are variable time step techniques, but this one happens to be fixed. Update() is run more or less frequently depending on how much your application demands from the system every step. So if you have a little code, it will take very little time to execute Update(). If you have alot or poorly designed code, then it will take longer to execute Update().

So here you can see that Update() and FixedUpdate() will usually be out of sync and you should do any physics related coding within FixedUpdate()

If you were to say, add force to a rigidbody toward the end of Update(), and your Update takes 0.5 seconds to execute. Well you skipped FixedUpdate() who knows how many times. That would reduce responsiveness of controls and the like.

if you want to know why they used a fixed time step physics engine check this post for pro and cons between fixed-time-step vs variable-time-step

http://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step

or this

http://gafferongames.com/game-physics/fix-your-timestep/

EDIT: If you understood how the fixed physics timestep affects the visual representation of the moved objects you might want to check this to achieve smooth movement of objects:

http://forum.unity3d.com/threads/162694-SmoothMovementTest-should-help-eliminate-Hiccup-sources



Hello All,

i am feeling very much thankful to all of you for your response that all are really very helpful for understanding the things.

Thanks Guyz…
Niki.j