Hello again! Another physics question for all y'all!

I've been working on a turn based strategy game lately. Obviously, the Godot docs are like the Godot Bible to me. One thing it mentions is that physics-related operations and queries (e.g. move_and_slide, raycasting) should be done in physics_process because to align with the physics step. In a turn based game though, the only changes to the physics space (at least that are obvious to me) happen during unit/pawn movement (assuming they are physicsbodies). While the player is deciding which pawn to move, everything is static. My current pathfinding algorithm for unit movement relies on making queries (possibly 10+ per path created) in order to find a valid path for a unit. So I doing only 1 query every frame is just too slow. So I've been doing them outside of physics_process and seems to not have any issues so far. My question is, in this situation, where it is guaranteed that nothing is changing - save the player's cursor location - does anyone have any insight as to if making these queries outside physics_process is generally safe? Or if there is a safe way to do this outside physics_process to keep speed up? I saw there's some good stuff in the docs about threads and thread safe operations, but not sure if it relates to the physics thread.

From what I understand of Godot and how the physics are setup, the reason you want to use _physics_process for anything physics related is so the physics you manipulate through code are in sync with the rest of the physics world. Especially for fast moving objects or time/gameplay sensitive physics nodes (bullets, triggers, etc), you generally want the physics you are manipulating to react to the "exact" state that physics are in. Without this, you could have issues like bullets traveling through the edges of players, as the physics state the bullets are using have the players in a different position than the render, leading to a disconnect between the physics and visuals.

With all of that in consideration, if your physics world does not change that often and the physics does not need to be perfectly in sync, then using physics functions and the like outside of _physics_process is probably safe enough. If you are not having any issues right now with using physics related queries outside of _physics_process, I wouldn't worry about it and move on. I might just leave a note in the code mentioning that it could potentially become out of sync with the visuals, in case you find it is causing a bug and need to change it later.

3 years later