I’m writing a network game with some physical gameplay. In order to apply client input on server side, I need rollback the whole physic scene to several frames ago.
I first search the document about Physics and Physics Scene, I can’t find any way to clone the whole physics scene to reuse it in the feature.
Then I decide to save all properties from rigidbody and other related data. But I found builtin physics engine is a stateful engine, there is no API to fetch those internal states.
For example, if I store the rigidbody properties after OnCollisionEnter was called and before OnCollisionExit is called. Then even if I restore all properties of this rigidbody like position, rotation, the physics engine still cannot treat this rigid body as being in collision, in other words, the OnCollisionStay won’t be called. It can easily reproduce if I teleport a rigidbody inside other colliders.
So my question is:
- Is builtin physics engine or physics scene can be cloned?
- If question 1 is NO, does it mean the only choice is to use 3rd physics engine or use Unity Physics for DOTS?