bevy_rapier icon indicating copy to clipboard operation
bevy_rapier copied to clipboard

add ability to force update transforms

Open cscorley opened this issue 3 years ago • 0 comments

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 Player B rollback. In B's client, the data is rolled back in both the Transform and the RapierContext, but the last_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., before A teleported), the Transform for A is updated once again. When frames are re-simulated, the object A 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.

cscorley avatar Oct 08 '22 20:10 cscorley