Search Unity

Semi authoritative server issue

Discussion in 'Scripting' started by Hybrid1969, Apr 15, 2014.

  1. Hybrid1969

    Hybrid1969

    Joined:
    Apr 19, 2013
    Posts:
    31
    have an odd problem. have the below code attached to the player object which has an animated character and a capsule.

    the script does the usual is.Mine to turn on/off controls for local/remote players as well as shows just the capsule on the server as a placeholder.

    works fine for the 1st connected player but stops working for any other connected player.

    what am i missing thats wrong with what im doing.

    Code (csharp):
    1.  
    2. void Awake()
    3.     {
    4.         if (networkView.isMine)
    5.         {
    6.             mseLook = GameObject.Find ("Player Camera").GetComponent<MouseLook> ();
    7.  
    8.             this.GetComponent<MouseLook>().enabled = true;
    9.             this.GetComponentInChildren<Camera>().enabled = true;
    10.             this.GetComponent<CharacterController>().enabled = true;
    11.             this.GetComponent<InGameMenu>().enabled = false;
    12.             GameObject.Find("Player Camera").GetComponent<AudioListener>().enabled = true;
    13.             GameObject.Find("Player Camera").GetComponent<MouseLook>().enabled = true;
    14.             Info.Instance.isAlive = true;
    15.             Info.Instance.playerObj = this.transform;
    16.         } else {
    17.             this.GetComponent<MouseLook> ().enabled = false;
    18.             this.GetComponentInChildren<Camera>().enabled = false;
    19.             this.GetComponent<CharacterController>().enabled = false;
    20.             this.GetComponent<InGameMenu>().enabled = false;
    21.             GameObject.Find("Player Camera").GetComponent<AudioListener>().enabled = false;
    22.             GameObject.Find("Player Camera").GetComponent<MouseLook>().enabled = false;
    23.             this.name += "-Remote";
    24.         }
    25.  
    26.         if (Network.isServer)
    27.         {
    28.             GameObject.Find("Graphics").GetComponent<MeshRenderer>().enabled = true;
    29.             GameObject.Find("Bip001 Pelvis").GetComponent<SkinnedMeshRenderer>().enabled = false;
    30.             //add player to server playerlist
    31.             svr_SpawnManager.Instance.playerList.Add(new PlayerList(this.networkView.viewID, this.gameObject, ""));
    32.  
    33.         }
    34.  
    35.         if (Network.isClient)
    36.         {
    37.             GameObject.Find("Graphics").GetComponent<MeshRenderer>().enabled = false;
    38.             GameObject.Find("Bip001 Pelvis").GetComponent<SkinnedMeshRenderer>().enabled = true;
    39.         }
    40.  
    41.     }
    42.  
    43.  
     
  2. Hybrid1969

    Hybrid1969

    Joined:
    Apr 19, 2013
    Posts:
    31
    i finally fixed this myself by going back to basics..

    A classic example of making a simple thing more complicated than it needed to be :D