Update before FixedUpdate?

I need to process some inputs in FixedUpdate (for controlling a rigidbody) but others in Update (such as selection of objects which should not be run multiple times per frame). I’d like to just get the inputs once and then use them in both Update and FixedUpdate, so I’m wondering whether Update runs before FixedUpdate or whether the two run in different threads and/or without any consistent sequence and therefore it may not work to get the inputs only once in Update? Previous forum posts on this subject are confusing and may no longer be valid for Unity 5.

Try printing a debug message in both in order to see which one gets called first.

FixedUpdate seems to run first (and of course sometimes several times in a row before Update), which is a problem because getting certain inputs in FixedUpdate can cause multiple redundant clicks.

Do not get the input inside of fixed update.
Get the input in normal Update and apply the force inside of fixed update.

Wouldn’t that sometimes result in inputs failing to be processed? Because you never know what sequence Update and FixedUpdate will be called during a given frame.

You should probably ignore that initial rush of FixedUpdate calls. My guess is, that’s Unity’s Physics engine initializing. If you let it run a bit and then check, you’ll see that a few Updates are called between each FixedUpdate (provided your frame rate is over 50fps). Also, as fffMalzbier said, check for input inside Update, not FixedUpdate. Update is called every frame. FixedUpdate is called at a fixed interval (by default, every 0.02 s).

So my suggestion is to get the input inside of Update and store the values in private variables so that FixedUpdate can access them.

1 Like