using fixed update

Hi,

I am a bit unclear on when to use fixedUpdate. In the same script I dont want to use fixedUpdate and Update as this seems a bit confusing. I know I use fixed update when a rigidbody is involved .With enemy characters I would need to use fixedupdate always as they would have a rigidbody instead of a charater controller?

Physics runs at a different frame rate to the rest of the game. For every “normal” game frame (I.e. a pass through everything’s Update methods) you might get none or multiple physics frames (I.e. a pass through everything’s FixedUpdate, OnCollision*, OnTrigger* methods). So if there’s stuff you need to ensure happens for every physics frame - such as applying custom forces - then you need to do it in FixedUpdate, not Update.

So for example if I want a rigidbody to move then I need to use fixedUpdate.

With fixed updates you can control how often the update runs rather than x times per frame refresh as just update runs. The beauty of this is that you have more control over the function because it’s a fixed rate rather than an unpredictable rate (update may run faster/slower on different hardware).

Not necessarily; for example if you just want to move it based on player input then you could do that in Update. But if you want to move it by applying physics forces, then yes, you need to do that in FixedUpdate.

ok how do i mark solved question?

You don’t. Other people may have further things to add, or corrections to make, after all.

ok thanks for the help and I will just leave this as is.