I have been looking for the answer to this problem but have not found any that solves the problem. The prefab is registered.
Here is the code piece, in the following class:
"public class MyNetworkManager : NetworkManager"
public override void OnStartServer()
{
NetworkServer.RegisterHandler(MsgTypes.PlayerPrefab, OnResponsePrefab);
base.OnStartServer();
SpawnCard ();
}
void SpawnCard () {
GameObject go = GameObject.Instantiate (theGuy) as GameObject;
NetworkServer.Spawn (go);
}
Can someone hint what the problem is?
I finally got it to work by doing the following in a NetworkBehaviour class, not NetworkManager:
public override void OnStartServer() {
SpawnCards ();
}
private void SpawnCards() {
GameObject go = GameObject.Instantiate (myGameObject) as GameObject;
NetworkServer.Spawn (go);
}
...which is basically the same but not NetworkManager class.