A general question…
If I am not using any rigidbodies should I still use FixedUpdate?
For instance I am moving an object through the game space by incrementing the position.x. Is there a benefit to FixedUpdate?
A general question…
If I am not using any rigidbodies should I still use FixedUpdate?
For instance I am moving an object through the game space by incrementing the position.x. Is there a benefit to FixedUpdate?
There are no benefits to using FixedUpdate for anything other than rigidbodies, only drawbacks. (Namely, higher CPU usage at those times when you least want it.)
–Eric
Totally agree. I just changed all my scripts over from FixedUpdate to Update and my FPS went from 10-15 to 20-30! (on Iphone)
Thanks.
As others said, not really, at least not technically.
Using FixedUpdate is slightly easier since you don’t have to do any special effort to make your code framerate independent. It is better to use Update and make the code framerate independent though.
For increasing or decreasing a value by some amount per second, you can just multiply your per seconds increment by Time.deltaTime, for example:
myValue += speed * Time.deltaTime;
For other stuff, things can gets slightly more complicated. For example, to have a value multiplied by some multiplier per second, you need to multiply with the multiplier raised to the power of Time.deltaTime. For example, if you want to have a value halved each second, you would do:
myValue *= Mathf.Pow(0.5, Time.deltaTime);
This is especially important to remember when doing damping in calculations, which are often handled by simply multiplying with some multiplier close to 1 each frame. You need to use the above formula if you want to avoid the damping acting different based on what the framerate is.
Rune