Execution order of events: Why are inputs processed after physics?

Normally, what I see in game loops is that inputting is processed directly after scene rendering.

Obviously, given a decent frame rate, a human isn’t going to be able to process and react to information portrayed directly after a single frame, but in theory, you normally want the player to be able to respond to the information that he’s given and trust that it reflects the actual state of the world. That’s the way I’ve always done it, and that’s they way I’ve always seen it done.

When you do some stateful processing (like updating physics) in between drawing the scene and taking input, then it can never be guaranteed that the player is reacting to events as they have been portrayed to him.

So why is Unity’s approach different? Why aren’t inputs processed immediately after a scene is rendered? Why is the state of the world updated between drawing it and getting the player’s reaction?

Well… none of us work for Unity, so we don’t really know why they chose why they do what they do.

Inputs are usually processed during your Update pass, which yes, Update comes after the physics simulation. And I could see a few reasons you might want to process logic after the physics has simulated, so that you can adjust the scene relative to the physics before things get rendered. Otherwise, physics will always be a frame ahead of logic, and logic is constantly playing catch-up, and you’d see this catch-up as jitter if the logic re-adjusts anything after physics moved it.

I could see an argument for an ‘EarlyUpdate’ that occurs as the first thing in the update loop, before physics, before everything, so that you could get inputs at that point.