The layout of the nodes in the tree determines the order of script execution. With everything expanded it simply goes top to bottom.
So if I had two characters moving at the same kind of speed and I wanted each one to fire a raycast onto each other one would fail since one will always be above or below each other in the scene tree? Is there anything I can do about that?
You can do direct raycasting for everything that requires it in a separate dedicated script that runs before anything moves.
That seems rather inconvenient compared to before but I guess I’ll give it a try. Thanks.
You can also stretch the colliders of moving targets in the direction of movement.
I also found that using call deferred on move and slide also seems to work, so I guess I can just defer any movement functions in-game, which also is a bit annoying but probably easier.
You can do that as well just don’t forget that not everything in a game will move through move_and_slide()
Another probably easier solution I’ve discovered; normally using force_update_transform() would work for this kind of stuff as it would update the target’s position right away but during testing this didn’t work because on Kinematic Objects like CharacterBody3D it’s broken. I did find a workaround; calling these lines after all movement allows the update to happen;
PhysicsServer3D.body_set_mode(self, PhysicsServer3D.BODY_MODE_STATIC)
force_update_transform()
PhysicsServer3D.body_set_mode(self, PhysicsServer3D.BODY_MODE_KINEMATIC)
Since we’re temporarily using the static body mode the transform update works regardless of the node order, which means that we call those lines either at the end of physics process to immediately update the motion or right before we call ray cast functions for example. Either way im pretty sure it works and is very easy to implement.
Note this only works if you aren’t running the physics on a separate thread.