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.
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.
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.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
190 People are following this question.
syncvar not changing after command
[UNET] How to disable an object across the network
NetworkServer.Spawn() only on Server (with registered prefabs) [Unity 5.2.3f1]
UNET (Multiplayer) calling [command] function twice
How to send Kinect skeleton data through Unity networks (multiplayer)