Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Netcode and Streamed Subscene Synchronization

Discussion in 'DOTS Dev Blitz Day 2022 - Q&A' started by Kmsxkuse, Dec 7, 2022.

  1. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    306
    Consider a situation where there are multiple subscenes (like megacity). Each subscene has multiple pre-spawned ghosts within them and synchronized.

    The server will have all of them loaded in order to properly simulate and authoritate the positions and events within them all but the client, for performance, will only have a select few subscenes open and loaded.

    What happens if the server determines that some of the pre-spawned ghosts in one subscene get deleted and a client later on loads that subscene? How do I make the server inform the client of the changes both in value and structurally that occurred before loading the subscene to entities within it? Is that automatic?
     
  2. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    331
    Thankfully, yes. :)
    Caveat: I'll need to research how it works when the server is unloading sub-scenes itself, as that may add nuances, but for now, I'd say to assume it works.
     
    Kmsxkuse likes this.
  3. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    306
    Do get back to me on server handing unloading as for now I'm moving forward assuming that all scenes are loaded on the server, requiring massive amounts of memory for empty / unused scenes.
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    933
    For prespawn there is a lot of automation done for you.

    The client automatically informs the server about which scenes that contains pre-spawned ghosts has loaded and the server only sync pre-spawned ghosts for the ones the client has loaded.

    If the server has destroyed some pre-spawned ghosts the client will be informed automatically to despawn them. Even if load the scene later.
    Client can also load/unload scene with pre-spawned ghost freely at will when they need and the Netcode package will handled that for you automatically as well.

    For ghost structural changes though we don't handle any of these.

    If the server unload a sub-scene with pre-spawned ghosts, and want the client do the same it need to inform the client to do so. But the pre-spawned ghosts will be de-spawned automatically anyway.
     
    Occuros and Kmsxkuse like this.