Skip to content

Commit 0c2735f

Browse files
committed
Clarify replication semantics (#464)
1 parent a163d4c commit 0c2735f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ A tick for an entity is confirmed if one of the following is true:
530530
531531
All events, inserts, removals and despawns will be applied to clients in the same order as on the server.
532532
533+
However, if you insert/mutate a component and immediately remove it, the client will only receive the removal because the component value
534+
won't exist in the [`World`] during the replication process. But removal followed by insertion will work as expected since we buffer removals.
535+
Additionally, if you insert a component into an entity that already has it, the client will receive it as a mutation.
536+
This happens because Bevy’s change detection, which we use to track changes, does not distinguish between modifications and re-insertions.
537+
As a result, triggers may behave differently on the client and server. If your game logic relies on this behavior, remove components before re-inserting them.
538+
533539
Entity component mutations are grouped by entity, and component groupings may be applied to clients in a different order than on the server.
534540
For example, if two entities are spawned in tick 1 on the server and their components are mutated in tick 2,
535541
then the client is guaranteed to see the spawns at the same time, but the component mutations may appear in different client ticks.

0 commit comments

Comments
 (0)