Пример #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Enemy"))
     {
         swordUI.DamagePlayer(other.GetComponent <Enemy>().GetDamage());
     }
     if (other.CompareTag("Spike"))
     {
         swordUI.DamagePlayer(10);
     }
 }
    void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.CompareTag("Player"))
        {
            swordUI.DamagePlayer(damage);
            Invoke("InvokeDeath", 0.5f);
            return;
        }

        ContactPoint[] points = collision.contacts;
        foreach (ContactPoint point in points)
        {
            if (point.otherCollider.CompareTag("Player Sword") || point.otherCollider.CompareTag("Shuriken"))
            {
                if (this.gameObject.activeSelf)
                {
                    DecreaseHealth(1);
                    StartCoroutine(HitEffects(point.point));
                }
            }
        }
    }