I can’t find an answer that works for me for this error. I’ve spent days and just can’t figure it out. I’m trying to make a multiplayer project, and it works to an extent, but when i spawn an object with NetworkServer.Spawn() or .SpawnWithClientAuthority(), i get an error saying “Failed to spawn server object, assetId= netId=2”
None of the answers i’ve found for other people seem to solve the problem. Here’s the code i know is relevant:
Class 1:
public class GUIControl : MonoBehaviour {
public virtual void SetupScene ()
{
if (canSpawnPlayer == true)
{
manager.SpawnPlayer(loadout);
}
}
}
Class 2, on my network manager:
public class MyManager : NetworkManager {
public void SpawnPlayer (Weapons.Loadout lo) {
MyControl.SpawnPlayer(lo);
}
}
Class 3, the object spawned automatically by the network manager upon joining,
public class MyControl : NetworkBehaviour {
public GameObject playerPrefab;
void Start () {
ClientScene.RegisterPrefab (playerPrefab);
}
public void SpawnPlayer (Weapons.Loadout lo) {
GameObject obj = Instantiate (playerPrefab, Vector3.zero, Quaternion.identity);
obj.GetComponent<Player>().loadout = lo;
NetworkServer.SpawnWithClientAuthority (obj, connectionToClient)
}
}
If anyone knows possible causes for this error, please let me know.