Improbable Icon

Forums

How should I handle rigidbodies synchronization?

unity

#1

If my game has a lot of rigidbody objects like moving platforms or joints, how should SpatialOS synchronize their states (position, velocity, force, etc.)? Because in my understanding, the result of the client and the server’s physical simulations are not precisely the same.

I guess each rigidbody has to be an entity, right? Then if only their positions are synchronized in every frame, the traffic overhead can still be huge.


#3

Hey @IndieST,

We’re currently experimenting with the Unity GDK to determine whether it makes more sense to treat rigidbodies as SpatialOS entities in their own right,or store the relative offsets of their joints in SpatialOS components. I’ve opened a task for us to fully document the exact process of synchronizing rigibodies once we settle on a best practice, so you’ll have more exhaustive guidance in the future.

We recommend that you make them separate SpatialOS entities for the time-being, and then make any necessary changes and optimizations when we publish our advised practice for this. If you have any other specific issues or questions regarding this, please let me know here and I can provide more guidance.

With regards to:

the client and the server’s physical simulations are not precisely the same

You’re correct, physics in Unity are non-deterministic. For this reason, you should model physics on your server-workers and only have your clients read and visualize the results of these physics interactions. You should always treat the SpatialOS world as your canonical source of truth.