I am getting very strange behavior, if my player instantiate as host (Server+Player) then my command function runs perfectly and certain object become instantiate but if I join the host then my Command doesn't execute on my local player but runs on all other clients.
void Start()
{
if (isLocalPlayer)
{
Debug.Log("It is VR Player spawn-Start");
SetVRLocalPlayerSetting();
//InstantiateMimicVRHeadAndController();
CmdInstantiateMimicVRHeadAndController();
}
else
{
Debug.Log("It is not vr Player its not isLocalPlayer");
DisableSelectedMonobevaiourScripts();
}
}
[Command]//This function have a problem
public void CmdInstantiateMimicVRHeadAndController() {
Debug.Log("instantiateing the controller and head object");
vrHeadCopyObj = (GameObject) Instantiate(vrHeadObjPrefab);
vrRightCtrlCopyObj = (GameObject) Instantiate(vrRightCtrlPrefab);
vrLeftCtrlCopyObj = (GameObject) Instantiate(vrLeftCtrlPrefab);
// spawn the bullet on the clients
NetworkServer.Spawn(vrHeadCopyObj);
NetworkServer.Spawn(vrRightCtrlCopyObj);
NetworkServer.Spawn(vrLeftCtrlCopyObj);
}