How to check if Player collides with trigger?

Hi! I’ve looked across the internet, but no answer has worked! I’m trying to make an enemy script with a Field of View that is a circle in a 2D scroller game, and I need it to be a trigger that triggers when the player collides with it to change a boolean to activate the enemy. The trigger works perfectly, but whenever I add an if statement to check if it’s the player and not anything else, it doesn’t do anything

void OnTriggerEnter2D (Collider2D other) { if (other.tag == "Player") { Debug.Log ("We been triggered"); } }

Check, has your player tag, exactly matching with the tag in your code.
If you want, use the CompareTag function. It is better than just comparing tags with == operator.

other.CompareTag("Player");

It’s also worth checking that you:

  1. Have a collider on your player
  2. Have a collider on the other object
  3. The colliders are both set to Trigger - I can’t quite remember off the top of my head whether OnTrigger needs the player’s collider to be set to trigger, or the other object, but if you set both to be a trigger and the problme goes, you can hopefully work it out from there :slight_smile: