I'm making a game that has no dynamic bodies, the only physics nodes are StaticBody2D, KinematicBody2D and Area2D. To keep smooth animation and responsive controls, I'm moving these bodies in _process
and it seems to be working fine. In Godot 3.1 alpha move_and_slide
even works correctly in _process
, so everything is very smooth looking and responsive.
The problem that overlaps are not running until the next frame at best. If you take a look at the main loop, it's iterating the physics engines to catch the physics simulation up to real time, but it's doing it before _process
meaning it's detecting overlaps from last frame's movements.
I realize running a physics simulation with a varying delta can result in unpredictable or undeterministic results, but in this case I don't care. I'm basically only interested in area overlaps and want them to happen much more responsively than they are now. As it stands right now if someone runs the game on a 144Hz monitor they could be waiting 2 to 3 frames before that 60Hz physics timer ticks over and even though that's a fraction of a fraction of a second, that's just a bit of lag that doesn't need to exist in a game like this. I could crank up the physics frame rate but even then at best there will be a 1 frame lag between action and reaction.
So what I'm really looking for is a way to manually run the physics engine myself at the end of _process
. I've poked around in the source code and the functions that would need to be called don't seem to be exposed to GDScript. I'm thinking this might be possible though since this is a common feature used to implement multiplayer games with synced physics.