Correct setup for replicating with Avian #941
cBournhonesque
started this conversation in
General
Replies: 1 comment 1 reply
-
|
Is there a way to sync Transform if Position does not exist? ie. for non-rigid bodies? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Avian uses 2 extra components
PositionandRotation, which it syncs to/fromTransformin itsPhysicsSet::SyncPlugin.There are multiple ways of settings replication with avian, and its tricky to gets things right.
1. Recommended
I like this setup because it makes sense that VisualInterpolation is applied directly to Transform, which is the component which affects the visual position of entities.
Also you don't have to modify the SyncPlugin of avian because by default it runs in FixedPostUpdate
The system order is:
Note that you cannot replicate Transform because the server will send the PostUpdate value of Transform which is computed after the Position->Transform Sync, and we update the history using the values before Sync, so you will get constant rollbacks.
Lightyear already provides the correct ordering constraints for this setup.
2. Only use Position/Rotation
Since you run VisualInterpolation on Position/Rotation, you will have to run avian's SyncPlugin in PostUpdate
The system order is:
(Note that lightyear already provides ordering constraints for this setup:
lightyear/lightyear/src/utils/avian3d.rs
Line 50 in 0f51455
3. Only use Transform
I think this could also work well, it would require to use the Transform->Position SyncPlugin.
I think I had some issues because Transform is updated multiple times (in VisualInterpolation, in TransformPropagate)
so you might have to run an extra SyncPlugin step in PreUpdate after RestoreVisualInterpolation but before CheckRollback.
It seemed tricky to get right so I haven't investigated further.
Beta Was this translation helpful? Give feedback.
All reactions