How to apply damage to another player with Mirror Network (Unity)?

369 views Asked by At

I am working on 3D multiplayer game with Mirror Engine and looking for the solution of following issues: I have a prefab "Vampire" which is spawned on server by different clients. When one vampire collides (OnTriggerEnter) with another, I want second one to be damaged...

I have methods at the same class:

private void OnTriggerEnter(Collider other)
{
    if (!isLocalPlayer) return;

    if (other.gameObject.tag == "Player")
    {
        other.gameObject.GetComponent<Player>().CmdApplyDamage();
    }
}

and

[Command]
public void CmdApplyDamage()
{
   this.healthPoints--;
}

OnTriggerEnter() works fine but CmdApplyDamage() is not called

0

There are 0 answers