Search Unity

Resolved Spawn a network object

Discussion in 'Netcode for GameObjects' started by lavagoatGG, Jul 26, 2022.

  1. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    229
    Hello,
    I am having an In-scene object with the network object component attached. The object is located in the same scene as my networkManager. It is being enabled only after calling the networkManager.StartHost() / Client().
    My problem is that the object is not being automatically spawned. I tried to spawn it from script but onEnable() is too early and the host isn't started yet.
    How can I make it spawn when the host is started?
    Thank you.
     
  2. itisMarcii_

    itisMarcii_

    Joined:
    Apr 5, 2022
    Posts:
    111
    There is an Event Called "OnServerStarted" in "NetworkManager.Singelton". You could subscribe to that Event and perform your code that way.
     
  3. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    229
    Thank you!