Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Netcode deffered World Creation / Destruction Crash

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

  1. Hysparions


    Jan 7, 2019
    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.

    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?