Skip to content
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

Dealing with Entity Relations #119

Closed
cBournhonesque opened this issue Jan 24, 2023 · 1 comment · Fixed by #162
Closed

Dealing with Entity Relations #119

cBournhonesque opened this issue Jan 24, 2023 · 1 comment · Fixed by #162
Labels
feature desired new functionality naia pertaining to naia crates

Comments

@cBournhonesque
Copy link
Contributor

Context

I am having issues handling relations between entities properly.
As an example; I have a 'Head' entity and a 'Segment' entity.
In the segment entity, I want to add a HasHead(EntityProperty) component that contains the head's entity.

If I just use naia's replication channel, i often get panics because the HasHead component gets sent to the server before the client has spawned the corresponding Head entity. The client cannot read the net_entity_id corresponding to the Head because it doesn't exist, and Naia panics.

Potential solutions

  • Naia has a mechanism where it waits for confirmation that the client has spawned the entity before sending the corresponding EntityProperty. This seems to work for messages, but not for components that get automatically replicated.

    • also, it's not ideal, because this adds a certain amount of latency before the HasHead component gets replicated between client and server
  • Add some kind of ordering system, where I can replicate a group of components from client to server, and the client will handle them in the same order?

  • Pre-reserve a set of entities on client/server so that we avoid panics when an net_entity doesn't match an entity in the Bevy world?

  • See how other networking libraries handle this issue

@cBournhonesque cBournhonesque added the feature desired new functionality label Jan 24, 2023
@ed-curran
Copy link

ed-curran commented Jan 29, 2023

I've also run into this difficulty, am curious if there's already a proper way to deal with it that i can't find.

Similar to your proposed second solution I was thinking maybe have a way to create related entities in a batch. Such that consistency of the relations only needs to be valid once the full batch is committed.

Also could have an eventual consistency thing where instead of panic when net_entity doesn't match, it just adds the net->bevy entity mapping of the missing entity and then hopefully in the future that entity will end up existing.

@connorcarpenter connorcarpenter added the naia pertaining to naia crates label Mar 20, 2023
connorcarpenter added a commit that referenced this issue Apr 23, 2023
Refactors related to EntityProperty and Entity Relations:
- Host no longer waits for remote Entities to spawn before sending Message EntityProperties containing a reference to them, they are just sent right away
- Remote will keep Messages & Components buffered separately from the world until their required Entities are spawned
- Addresses #119 ?

Other small changes:
- The Bevy demo now uses default Bevy, which may resolve #156
- Certain warning logs have been suppressed, which were only previously used for testing purposes. Their removal should give some peace of mind for people having issues like #160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature desired new functionality naia pertaining to naia crates
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants