Example #1
0
    void OnTriggerEnter(Collider other)
    {
        Quaternion oppositeBulletRotation = Quaternion.LookRotation(-transform.forward); //transform a direction in a rotation

        switch (other.tag)
        {
        case "Enemy":
            Zombie zommbie = other.GetComponent <Zombie>();
            if (!zommbie.dead)
            {
                zommbie.Damage(10);
                zommbie.BloodParticle(this.transform.position, oppositeBulletRotation);
                _gameManager.ShakeCamera();
            }
            break;

        case "Boss":
        {
            BossControl boss = other.GetComponent <BossControl>();
            if (!boss.dead)
            {
                boss.TakeDamage(1);
                boss.BloodParticle(this.transform.position, oppositeBulletRotation);
                _gameManager.ShakeCamera();
            }
        }
        break;
        }
        Destroy(this.gameObject);
    }