Command function called on server
When i try to run a command function from a script attached to my player object, while the player client is connected to the server, it does not run. Instead, I get this error:
Command function CmdPlayerSpawned called on server.
UnityEngine.Debug:LogError(Object)
playerMove:CallCmdPlayerSpawned()
playerMove:Start() (at Assets/Player Scripts (PROJ_S)/playerMove.cs:71)
This is the relevant piece of code from my player script. I can post more if needed.
     [Command]
     void CmdPlayerSpawned()
     {
         GameObject player = (GameObject)Resources.Load("Player", typeof(GameObject));
         ClientScene.AddPlayer(playerControllerId); //trigger NetworkServer.AddPlayerForConnection on the NetworkManage.cs
         ClientScene.RegisterPrefab(player); //registers the player prefab with the server so that it can be spawned on clients later
 
         GameObject NetworkManager = GameObject.Find("NetworkManager");
         NetworkManager.GetComponent<NetworkManage>().playerSpawnOnClient(); //calls playerSpawnOnClient from the Network Manager to make this player spawn on every client, not just the server
     }
 
               All of that is inside a NetworkBehaviour class.
Your answer
 
             Follow this Question
Related Questions
How to send Kinect skeleton data through Unity networks (multiplayer) 0 Answers
Why do I need [Command] for NetworkServer.Spawn() , but not for NetworkServer.Destroy()? 0 Answers
Using joints with UNet Not Working Correctly 0 Answers
Get name/variables from previously on server players 0 Answers
How to use the ".Assetbundle" file to load the resources to make it work in network? 0 Answers