Search Unity

Multiplayer bullet damages

Discussion in 'Multiplayer' started by KevinBarroso, Apr 19, 2017.

  1. KevinBarroso

    KevinBarroso

    Joined:
    Apr 18, 2017
    Posts:
    1
    Hello !

    I'm starting Unity and to begin i would like to create a little shooter.
    Everything is working fine except the bullets, when they collide nothing happen.
    I did a check on the playerController if oncollisionenter the tag is weapon bam it call a function that reduce the health :

    Code (CSharp):
    1.  
    2.   [Command]
    3.     public void CmdReiceveDamages(int amount)
    4.     {
    5.         currentHealth -= amount;
    6.     }
    7.  
    I dont get what's wrong, when it collide this function tell to the server hey i'm touched !

    Code (CSharp):
    1.     public void OnCollisionEnter(Collision collision)
    2.     {
    3.         if (isJump)
    4.         {
    5.             isJump = false;
    6.             audio.PlayOneShot(sounds[3]);
    7.         }
    8.         if (collision.collider.tag == "bullet")
    9.         playerHealth.CmdReiceveDamages(20);   //The function called to reduce health
    10.     }
    Anyone have any idea ?