Cannot Spawn object without an active server

Hi, so I’m trying the new Network system of Unity, and I got some Issues, I can’t find a answer on internet, I’m trying to instanciante and Spawn GameObjects but I go this error :

SpawnObject for Map Manager(Clone) (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server.

So I don’t know why Network server is not active, I got this error when I click on “LAN Host(H)” with the Network Manager HUD,

I’ve made this networkManager to instanciate my Managers on the server when the server is started :

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class NetworkManagerScript : NetworkManager {

    public GameObject[] ListToSpawn;

    public override void OnStartServer()
    {
        foreach(GameObject obj in ListToSpawn)
            NetworkServer.Spawn(Instantiate(obj)as GameObject);
    }
}

I don’t know why I got this error, probably something I’m doing wrong, I hope for a answer

Thanks :slight_smile:

Same problem here. The lack of help on the unity forums is really disgusting. I wonder if the Unreal engine has better support.

if (!isServer)
return;
add this before to spawn. because client can’t spawn.

1 Like

What @wstcgez said should be the solution. This is because according to documentation OnStartServer is also invokved on a “host”. Meaning it will be invoked on the Host Client aswell
https://docs.unity3d.com/ScriptReference/Networking.NetworkBehaviour.OnStartServer.html

Используйте Coroutine и while (true).

base.OnStartServer() before your code ? maybe maybe not :slight_smile: