- Home /
 
               Question by 
               White8eard · Sep 30, 2015 at 12:01 PM · 
                c#networkinginstantiatespawn  
              
 
              How to to spawn player, according to id?
i am trying to spawn player and the enable their mesh according to their id from client, i am able to create the player right, when player a picks cop and hosts server, and player b picks plumber and joins the server.But in Host View the player A and B both have the cop mesh enabled instead of CoP/Plumber Mesh, While in Client(player B view) both the objects are running but both have their meshes disabled. how do i make them to spawn with right mesh?
 public int charID;
 
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
        
     }
 
     public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
     {
         if (charID != GameObject.Find("GameManager").GetComponent<InGameUI>().CharID)
             charID = GameObject.Find("GameManager").GetComponent<InGameUI>().CharID;
         GameObject player = Instantiate(playerPrefab,Vector3.zero,Quaternion.identity) as GameObject;
         if(charID==1)
         {
             player.transform.FindChild("Cop").gameObject.SetActive(true);
         }
         else if(charID==2)
         {
             player.transform.FindChild("Plumber").gameObject.SetActive(true);
         }
         //
         NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
     }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                