Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feature Request Child ghost entity elimination

Discussion in 'NetCode for ECS' started by optimise, Jan 24, 2023.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,114
    Since child ghost component is bad for performance, I would like to propose improvement at ghost authoring component monobehavior that will have an option eliminate child ghost entity when baking so you will no longer have child ghost component anymore. The idea is u have game object attached ghost authoring component monobehavior and that game object has multiple child game objects. When u tick flatten child ghost entity option at ghost authoring component, all the child ghost entities that belongs to parent ghost entity will be flatten and no longer have child ghost tag component. So they become fake child ghost entity that technically it's now become like parent entity. So now it will looks like when u instantiate an ghost entity, you further instantiate multiple ghost entities and then associate all the entities with the entity u instantiate previously.

    But since Entities Hierarchy windows still dun have entity grouping feature like System window that able to group multiple systems into as a group, I think the workaround for now is when baking removing all the transform related components and only leave Parent component to do entity association.
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    882
    I have to re-read this again, but if I understood correctly you suggest something like this:

    Ghost A (ID = 10)
    Child B
    Child C
    Child D

    With the current implementation, it would be serialized like this:

    GhostID 10: Data : A B C D

    Ghost parent and child data are always sent together.

    With your suggested changes this will generated 4 different ghosts:

    Ghost ID 10 A
    Ghost ID 10.1 B -> relate to A
    Ghost ID 10.2 C -> relate to A
    Ghost ID 10.3 D -> relate to A

    Since now this are "disjointed" ghosts, they aren't sent atomically anymore. They also can belong all to different chunks.
    To give the atomic guarantee, the send logic need quite substantial changes. Or, we may choose to lose that guarantee, and in that case you should opt for it.

    Dunno how this is going to perform better in case we want to have the same atomic guarantee (ghost parent and child are always sent together). The logic necessary is not trivial to implement and may not be necessarily faster in the end.
     
  3. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,114
    Is that really work like that with the current implementation? From what I know you need to tick ghost group option at ghost authoring component to achieve that.

    I see. Seems like need to do some testing first to prove whether it's worth to implement this feature or not. For now, I think can optimize same parent ghost entity back to same chunk first since current implementation is every parent ghost entity is at completely new chunk at both client and server even both entities have the same set components. It's the temporarily fix for the bug I mentioned last year.