private void OnTriggerEnter(Collider col) { // detects if the player is touching an object and deletes its collider to not trigger it again if (col.transform.tag == "wall") { Hit.pitch = Random.Range(0.5f, 1); Hit.Play(); StartCoroutine(Blink()); StartCoroutine(Glitch()); Debug.Log("got hit by " + col.transform.name); l.SetHealth(l.GetHealth() - 1); Destroy(col.GetComponent <Collider>()); if (l.GetHealth() >= 1) { hitEffect.Play(); } else { deathEffect.Play(); } } }