Topic was automatically imported from the old Question2Answer platform.
Asked By
nsobject
Does _physics_process on nodes get called in strict deterministic order or it is gets called in arbitrary, unpredictable order?
Can we control and reorder this?
My goal is always update moving platforms before player & enemy or any other character.
_physics_process and _process both seem to be called in pre-order traversal from the root node (basically, nodes are processed in order from the top to the bottom of the scene view). There doesn’t seem to be a way to change this order. I would urge against designing anything that relies on the order of update calls, though.
In a well designed engine/game, all physics movement is calculated at one time, then the reactioned are then calculated. For instane, if you were playing Street Fighter 2 and you both hit each other at the same time, what happens is that you both receive damage. But, in a badly deigned game, the player who was calculated last in the code is the one who gets hit.
This is a more in depth article (but not too in depth):
I have no doubt this is how Godot works: it calculates all movement at the same time. It’s always best to rely on the Godot engine to do all the work, as it is written by people who have years of experience in games and game engines. If you want the platforms to have precedence, I would recommend using a static body and just moving those around.
“It’s always best to rely on the Godot engine to do all the work, as it is written by people who have years of experience in games and game engines.”
Really?
Truth be told, ‘Kinematic Character’ demo is awful: unresponsive player controls, character lags after moving platform, jumps on down moving platform, moving on slopes is terrible.
nsobject | 2018-02-07 11:56
agree. Now I found that Godot 3.0 has bugs on the physics side…
the _physics_process call order would be A,D,E,B,C,F.
Now if you were, for example, to set F’s process priority to -1, and D’s process priority to 1, the call order would change to F,A,E,B,C,D
I tested this by creating a scene tree where every node just prints their name during the _physics_process. According to it, Godot will process in the exact order in which the nodes are listed in the tree view, ignoring parentage, provided they all have the same process priority (which by default is 0 for all nodes).