Question by 
               Moaid_T4 · Feb 17, 2016 at 02:20 AM · 
                networkingmultiplayernetworkshooterfirst person shooter  
              
 
              Only Host Can Damage Players In A Network Match
hello, im using a fairly simple setup for a multiplayer test game but i cant get a client to harm a host/another client, only the host can, code :
 void Start () {
         HUD = transform.FindChild("HUD").gameObject;
         healthBarTP = HUD.transform.Find("Health Bar").GetComponent<Slider>();
         cam = transform.FindChild("Camera");
         ch = GetComponent<CharacterController>();
         if (isLocalPlayer)
         {
             old_state = normal;
             healthBar = GameObject.Find("Health Bar").GetComponent<Slider>();
 
             healthBar.minValue = 0;
             healthBar.maxValue = maxHealth;
             healthBar.value = health;
 
             HUD.SetActive(false);
         }
         else
         {
             cam.gameObject.SetActive(false);
             gameObject.layer = LayerMask.NameToLayer("remotePlayer");
 
             healthBarTP.minValue = 0;
             healthBarTP.maxValue = maxHealth;
             healthBarTP.value = health;
         }
     }
 
     [Command]
     public void CmdDamagePlayer(int dmg)
     {
         RpcTakeDamage(dmg);
     }
 
     [ClientRpc]
     public void RpcTakeDamage(int dmg)
     {
         health -= dmg;
         if (health <= 0)
         {
             health = 0;
         }
         if(isLocalPlayer)
             healthBar.value = health;
         else
             healthBarTP.value = health;
     }
 
     // Update is called once per frame
     void Update () {
         if (isLocalPlayer)
             healthBar.value = health;
         else
             healthBarTP.value = health;
 
         if (isLocalPlayer)
         {
             Look();
             Move();
             if(Input.GetMouseButtonDown(0))
             {
                 Shoot();
             }
         }
     }
 
     private void Shoot()
     {
         if(Physics.Raycast(cam.position,cam.forward, out hit, distance,mask))
         {
             if(hit.transform.tag == "Player")
             {
                 hit.transform.GetComponent<FirstPersonController>().CmdDamagePlayer(damage);
                 print("hit player");
             }
         }
     }
i get this warning message : Trying to send command for object without authority. i guess clients cant call commands or something ?? any way whats the correct way to do it :D, thanks
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                