void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { // if an enemy collides with the player, the player escapes the enemy Diver diver = other.gameObject.GetComponent <Diver>(); diver.EscapeEnemy(); } }