0
\$\begingroup\$

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);     
}
\$\endgroup\$
  • \$\begingroup\$ other means the server.no i dont have any other player. I just make a demo and find that command only runs on server not on other client or local player \$\endgroup\$ – Muhammad Faizan Khan Feb 2 '17 at 10:05
  • \$\begingroup\$ Ah, I'm completely off-base on this one. Anyway I've found this, maybe it'll help: forum.unity3d.com/threads/… \$\endgroup\$ – John Hamilton Feb 2 '17 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.