-
-
Notifications
You must be signed in to change notification settings - Fork 38
Stepping Physics with Rollback #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <kumpulainen.matias@gmail.com>
Co-authored-by: Matias Kumpulainen <kumpulainen.matias@gmail.com>
Co-authored-by: Matias Kumpulainen <kumpulainen.matias@gmail.com>
Co-authored-by: Matias Kumpulainen <kumpulainen.matias@gmail.com>
@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 <kumpulainen.matias@gmail.com>
Co-authored-by: Matias Kumpulainen <kumpulainen.matias@gmail.com>
Co-authored-by: Matias Kumpulainen <kumpulainen.matias@gmail.com>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made sure that the signal handlers are disconnected if the node is not in the tree
Co-authored-by: Matias Kumpulainen <kumpulainen.matias@gmail.com>
Co-authored-by: Matias Kumpulainen <kumpulainen.matias@gmail.com>
Co-authored-by: Matias Kumpulainen <kumpulainen.matias@gmail.com>
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