private void OnCollisionEnter2D(Collision2D collision) { if (enabled && collision.otherCollider.CompareTag("Player")) { PlayerCharacter player = collision.gameObject.GetComponent <PlayerCharacter>(); player.Die(); } }
private void OnTriggerEnter2D(Collider2D other) { if (enabled && other.CompareTag("Player")) { PlayerCharacter player = other.GetComponent <PlayerCharacter>(); player.Die(); } }
private void OnEnable() { if (col != null) { List <Collider2D> hits = new List <Collider2D>(); if (Physics2D.OverlapCollider(col, filter, hits) > 0) { foreach (Collider2D hit in hits) { PlayerCharacter player = hit.GetComponent <PlayerCharacter>(); if (player != null) { player.Die(); } } } } }