Ejemplo n.º 1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == tagToHit)
        {
            HealthHandler hp = other.GetComponent <HealthHandler>();
            if (hp)
            {
                hp.ChangeHp(-damage, false);
            }
            else
            {
                Debug.Log(name + ": does not have a HealthHandler");
            }
        }
        if (!other.isTrigger && other.tag != tagToIgnore)
        {
            AudioSource.PlayClipAtPoint(impactSound, GameObject.FindGameObjectWithTag("Player").transform.position);
            Destroy(gameObject);

            Debug.Log("Hit " + other.gameObject.name);
        }
    }