-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scene replication #376
Comments
Adding The problemThe issue is that if you attach Possible solution
But what if the scene hasn't been spawned by the client yet? 🤔 This means we need to spawn it as part of the replication process (just to know scene entities), which might require embedding scene spawning into replication. Currently, to replicate a scene, the user simply replicates a marker and initializes the scene manually in a system. Another option would be to buffer scene entities until the scene is spawned. Could store scene entities as slices of Maybe you have another ideas? Mapping could be encoded in the replication message like this
1 and 2.2 will be mapped to client-local entities, and 2.1 is already known by the client. We have two kinds of replication messages: bevy_replicon/src/core/replication/update_message_flags.rs Lines 8 to 13 in 6b9bd43
We might need to add another section for scene mappings. Prior artBoth Unreal Engine and Godot allow replication to be enabled for every actor or node in a scene. It would be nice to look at their approach 🤔 |
I was not suggesting adding ReplicationId to every entity, only descendant entities which you want to be replicated to an entity spawned by the client. I think this issue is more general than scenes. It applies to any hierarchical structures. The method of spawning a scene with a marker Component seems reasonable to me to keep the same. The problem is matching up the child entities. I think buffering scene entities (really, anything with ReplicationId) is the right move. It seems like replicon already does some client side buffering for another purpose (though I didn't look to closely at why). |
Ah, got it! I would consider hierarchical replication as a separate thing. For scenes we only need to match entities once on scene spawning. If we solve this, attaching
Yes, we buffer mutate messages to apply them only if update message is received. Before I write detailed information about the implementation, we need to figure out how to properly generate IDs. Looks like the upcoming BSN format won't have |
I think maybe we are still talking past each other. What I mean is: the problem in my mind is replicating things which, as part of their spawning, spawn child entities which need to be replicated. (I'm not, and haven't been, talking about changes to hierarchy) A scene is one example where this is useful. It also has an extra constraint.
Thinking in terms of the current Marker component method for spawning.
Really at the low level the problem is the replication of entities that (on the client) must be spawned by client code. Replicon currently assumes that anything it replicates to the client, it also spawns on the client (ignoring prespawning).
So to this, I would say, I think (optional) ID based replication is more important/fundamental. Technically the IDs don't even need to be generated by replicon (though I do think we should provide a solution, but if BSN is evolving it might not be a super stable one). |
There is no issue here. You can spawn hierarchies on the server with The scene use case is completely different. You want to have base entities on both the client and server and receive updates to these values if they change. There is no need to introduce custom IDs for hierarchy replication. We need them specifically for scenes to determine which scene entity belongs to which spawned entity. |
...spawns children that themselves need replication. I should have been more clear. I maintain that scenes are only a single instance of the more general client side / symmetric spawning problem. Which I suppose is potentially more general than hierarchical structures, just any group of entities spawned by the same code. |
Yes, I get this. It's supported. With both spawning on server and pre-spawning on client.
I can't think of any use case other then scenes. For all other use cases you can use regular replication from server or pre-spawning. |
I don't get how currently you can accomplish this with the pre-spawning system. It seems like the client must spawn the entity first, because it has to give the server the entity ID. Maybe I don't actually get how pre-spawning works, it does seem bizarre and roundabout to me. At least this example: https://docs.rs/bevy_replicon/latest/bevy_replicon/server/client_entity_map/struct.ClientEntityMap.html A) is not symmetric |
That's the whole idea of pre-spawning. You spawn entity or entities and notify server about them. Then server spawns, and client will receive replication as like they were spawned on server. It's useful if you want to hide delay on client, typically needed for prediction for fast-paced games. If you don't need to spawn on client first - you just spawn things on server. If you also want to replicate the hierarchy - you insert
Yes, it's completely different from the scene case. |
My (rough draft) proposal for replication of scene children (and other client spawned entities).
Generic case:
Scene case:
ie.
123/my/scene/ball_12
where 123 is the server entity_id of a replicated entity ( most likely with a MySceneSpawner or such component )Potential issues:
Prior art:
I haven't been able to find anything specific to scene replication.
Inspiration for using a deterministic hash for mapping comes from how lightyear does prespawning.
https://docs.rs/lightyear/latest/lightyear/client/prediction/prespawn/struct.PreSpawnedPlayerObject.html
The text was updated successfully, but these errors were encountered: