update { }

Does update exactly look at each object once per time segment? Does it do it in the same order every segment?

I’ trying to move 2 objects are once with one keystroke. Seems like one is working intermediately and the other is working 100% of the time. I didn’t know if there was some timing issue here. The movements have to be precise since its the shifting of a UV map for both meshes an exact amount of pixels. So basically each key click moves the map X or Y pixels in a certain direction.

Update runs once for each MonoBehaviour. There is no guarantee that it does this in the same order each time. If you are using the Input class, this class is updated before any Update functions are called.

Unfortunately, I don’t think we’ll be able to help figure out why one is working sometimes and the other works always unless you give us some code!

So basically just for example…

if I have 10 objects that look for a key press.

The key press will be detected
Then update runs on all 10 objects and they will all get the input update the same way once during the frame
The update is over and the input is reset

I ask to determine if its my code or internal mechanics. If the above is true and all 10 objects will behave the same way when the input is done then its my code.

Yes. That is how it should work.

Eg. Input.GetKeyDown(KeyCode.RightArrow) is set just before Update() is run, and will return the same value for all Update() functions in a frame. It will not change between different objects until the next Update() frame.

script execution order does guarantee the order afaik.

thats how i would assume it to work.

I was curious about this and found the Script Execution Order settings. According to that doc, the script order is guaranteed if explicitly set.

It does not say anything about Update() order if 100 objects have the same MonoBehaviour on them. I wish I had time to test and find out, though I usually will assume no guarantees about order unless some documentation or code states otherwise.

I would randomly assume that it will call it in the order that the components were created