Search Unity

How do I prevent ghost components from being removed in a world without a connection?

Discussion in 'NetCode for ECS' started by NovaEiz, May 7, 2021.

  1. NovaEiz

    NovaEiz

    Joined:
    Sep 6, 2017
    Posts:
    53
    What need to do to prevent ghost components from being deleted in a world where there is no connection, but the components are needed?


    I've disabled all the ghost systems.
    And in the source code, I can't find any code that removes the ghost components.

    I solved my problem using a crutch by adding the "Prefab" component. But this is just to check that the components remain and what I need works as it should. But this will not work through Foreach if I need it in the future.

    What should I do?
     
  2. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    Not sure I understand what you are trying to do.

    We do not remove components from ghosts - except if the components are marked as server only or client only.

    On the server we do not automatically destroy any ghosts.

    On the client we destroy all ghosts when the connection is lost since those ghosts are owned by the server and you are no longer connected to a server.
    If you want to keep some state in this case you should probably create a local entity when a ghost is spawned and keep that local entity around after a disconnect.
     
  3. NovaEiz

    NovaEiz

    Joined:
    Sep 6, 2017
    Posts:
    53
    It turned out that it was my system that was removing these components.
    It's strange that I couldn't find it by searching in Rider...

    Now I feel the great power of DOTS NetCode as much as possible, after a year and a half of developing the code of the multiplayer game project. I get really high.
    Thank you Guys for a great job!)