예제 #1
0
    //triggers damage on hit
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("HIT");
        if (other.gameObject.CompareTag("Player"))
        {
            Player_Combat pc = other.GetComponent <Player_Combat>();
            pc.PlayerTakeDamage(damage);
            gameObject.SetActive(false);
            SpawnEffect();
        }
        else if (other.gameObject.CompareTag("Enemy") && !EnemyFired && Uncontrollable)
        {
            Debug.Log("enemy hit");
            gameObject.SetActive(false);
            EnemyCombat ec = other.GetComponent <EnemyCombat>();
            ec.EnemyTakeDamage(damage);
            SpawnEffect();
        }

        else if (other.gameObject.CompareTag("Enemy") && !EnemyFired && !Uncontrollable)
        {
            gameObject.SetActive(false);
            EnemyCombat ec = other.GetComponent <EnemyCombat>();
            ec.EnemyHeal(damage);
            SpawnEffect();
        }
    }