Search Unity

Netcode deffered World Creation / Destruction Crash

Discussion in 'NetCode for ECS' started by Hysparions, Jul 19, 2020.

  1. Hysparions

    Hysparions

    Joined:
    Jan 7, 2019
    Posts:
    29
    Hello everyone,
    I am currently working on a project using DOTS, and I want some multiplayer functionalities for my game. I want it to have a local "Sofa" mode where player(s) can use the game without server / Internet Connection. This Local mode can use keyboard or Console controller to run 1-4 players

    Correct me if I am wrong
    This mode would require only one world for entities => client world without server

    Then, I want to have a multiplayer mode where one of the 4 players host and other join using ip address.
    This mode would require one world for client, and one for the server.

    Those two modes force me to create the client or client / server world when the user select the mode he wants to play.

    I tried first to follow these instructions about how to create client and client / server worlds.
    https://docs.unity3d.com/Packages/com.unity.netcode@0.0/manual/client-server-worlds.html

    Everything works fine for me, I click on a button, the worlds are created, but when I stop the play button of the editor, the entity debugger still shows that the worlds are here, like if they were not destroyed. moreover, when I try to re-launch with the play button, unity crashes…

    I finally used World.DestroyAllWorlds() in my gamemanager monobehaviour OnDestroyCallBack()
    which works fine (but give me exceptions of entity debugger comming from entity packages) it seems like a Dirty solution...

    I may have misunderstood Something about how worlds are destroyed, but couldn't find many support in the doc. Can someone tell me how to properly destroy worlds on application quit or Play Stop pressed in the editor?