Search Unity

Question Correct timing to spawn NetworkObjects

Discussion in 'Netcode for GameObjects' started by mishakozlov74, Jan 23, 2023.

  1. mishakozlov74

    mishakozlov74

    Joined:
    Aug 8, 2018
    Posts:
    143
    Hey, I'm working on a coop game, I use internal network scene management and I faced a problem with spawning dynamic network objects.

    Host loads the scene, all clients catch up with it, so eventually I have
    OnLoadEventCompleted event, when I assume that I can spawn NetworkObjects.

    The problem is, I load scenes in additive mode and the loaded scene isn't the active one on my clients, so all spawned network objects go to the old one (on clients), which is getting unloaded after a moment, so I have an errors.

    The question is, how do I spawn network object in a specific scene? It's kinda odd that synchronization doesn't take care about the scene, when the server can literally broke everything by simply unloading the scene where it doesn't store network objects, while clients actually do.

    Thanks!