Stepping Physics with Rollback #437
Conversation
|
Nice work on the toggles @elementbound I havent forgottten about this PR, just that time of year where I'm traveling a bit and don't get as much time to work on things. Working on a RollbackSynchronizer Player driven RigidBody at the moment. It's a bit tricky as the pattern is a little different to what you would do with a CharacterBody. Generally movement is all self contained in rollback_tick. When dealing with RigidBodies we need to let all RigidBodies take in what forces they will have, run the physics simulation for a step and then save the snapshots. |
There was a problem hiding this comment.
Noticed that a CharacterBody's collider transform doesn't ever update unless force_update_transform is called, resulting in 'ghost' colliders. Not sure if there's a more elegant solution, but this works.
From my testing all the relevant CharacterBody transforms need to be updated on both _snapshot_space and _rollback_space, otherwise the collider might skip an update occasionally when the game window loses focus 🤷
|
Rapier seems to have a bunch of collision issues for me, but these might not be fixable in the rollback code:
Here's the project I used to test these out: https://github.com/kumpmati/netfox-physics-rollback-test |
Co-authored-by: Matias Kumpulainen <[email protected]>
Co-authored-by: Matias Kumpulainen <[email protected]>
Co-authored-by: Matias Kumpulainen <[email protected]>
Co-authored-by: Matias Kumpulainen <[email protected]>
|
@kumpmati Thanks for picking up on the 2D and CharacterBody issues. Still looking into all its variations. Its mentioned here also:
Yeah, Rapier has its own issues. Collision seems to be spotty unless the surface is really thick. |
Co-authored-by: Matias Kumpulainen <[email protected]>
Co-authored-by: Matias Kumpulainen <[email protected]>
Co-authored-by: Matias Kumpulainen <[email protected]>
| func step_physics(_delta: float) -> void: | ||
| # Break up physics into smaller steps if needed | ||
| var frac_delta = _delta / physics_factor | ||
| var rollback_participants = get_tree().get_nodes_in_group("network_rigid_body") |
There was a problem hiding this comment.
get_tree().get_nodes_in_group(...) crashes the game if the scene with the driver is reloaded, since the driver is removed from the tree momentarily.
There was a problem hiding this comment.
Made sure that the signal handlers are disconnected if the node is not in the tree
Co-authored-by: Matias Kumpulainen <[email protected]>
Co-authored-by: Matias Kumpulainen <[email protected]>
Co-authored-by: Matias Kumpulainen <[email protected]>


Helper classes for supporting physics stepping and rollback.
Auto-stepping is disabled and taken over by the netfox loop.
Physics implementations supported:
Progress
Closes #265