add ability to force update transforms #261
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change allows for transform updates to always be applied.
In my physics simulation, I have a teleporting collider that is positioned based on user inputs. This simulation exists in a rollback networking-based game, where every public property of
RapierContext
is restored from a previous serialization upon rollbacks.This change solves an issue when an Player
A
teleports their object, which causes PlayerB
rollback. InB
's client, the data is rolled back in both theTransform
and theRapierContext
, but thelast_body_transform_set
is not since it is not public outside of the crate. Since rollbacks re-simulate the inputs using the save state of the prior frame (e.g., beforeA
teleported), theTransform
forA
is updated once again. When frames are re-simulated, the objectA
teleported is ignored on the resulting frame which causes a desync between the physics state of the two clients.I have implemented this as a configuration option because I find it useful to conditionally toggle it during rollbacks only. This allows updates to only be forced during certain frame re-simulations rather than all the time.