Search Unity

Help Wanted Client Error: Failed to spawn server object

Discussion in 'Multiplayer' started by kentzeus, Jul 16, 2020.

  1. kentzeus

    kentzeus

    Joined:
    Mar 1, 2020
    Posts:
    9
    Hey, I have both dragged the prefabs into the inspector and registered it in the networkmanager script but it still doesn't work. On the server everything works as expected.
    Code (CSharp):
    1. public class NetworkManager : Mirror.NetworkManager
    2. {
    3.     public override void OnStartClient()
    4.     {
    5.         var spawnablePrefabs = Resources.LoadAll<GameObject>("Assets/Prefabs/Spawnable");
    6.         for (int i = 0; i < spawnablePrefabs.Length; i++)
    7.             ClientScene.RegisterPrefab(spawnablePrefabs[i]);
    8.     }
    9.     public override void OnStartServer()
    10.         => spawnPrefabs = Resources.LoadAll<GameObject>("Assets/Prefabs/Spawnable").ToList();
    11. }
    I get these two errors:
    Failed to spawn server object, did you forget to add it to the NetworkManager? assetId=e34ffb03-4678-de04-9ab1-51775452d25a netId=3
    Could not spawn assetId=e34ffb03-4678-de04-9ab1-51775452d25a scene=0 netId=3

    Any suggestion on how to solve this issue?
     
    Last edited: Jul 16, 2020
unityunity