Not Detecting Trigger Collision

I have the following code:

private void OnTriggerEnter2D(Collider2D collision)
        if(collision.gameObject.tag == "MainCamera")
        if(collision.gameObject.tag == "Player")

The object that owns my main camera has a CircleCollider2D component attached to it, but the game object that owns the above method does not detect the collision (see first DebugLog.) It does, however, detect the main player (second Debug.Log). Since the camera is positioned to follow the main character, both of their colliders occupy essentially the same space, so I am mystified why it can’t detect the camera’s collider. (I would just base the collision off the player, but this design would break down in multiplayer). I verified that the camera has a 2d collider, and that it is a trigger collider. The collision layer matrix is also configured so that they should be able to collide. The game object that owns the camera is also a child of another game object, which is just an empty game object I used to group a bunch of UI/camera related objects together. Does the physics engine ignore game objects with cameras on them? Am I missing anything? Let me know if more detail is needed. Thanks in advance!

You should use CompareTag to see if a GameObject has a certain tag so you get warnings if it’s invalid. (it’s also more performant)

Physics message troubleshooting is quite detailed, but if you’re seeing one condition trigger and another not, then the issue is with that object.
Either with the tags, the trigger matrix setup is incompatible, or perhaps it’s dynamic and isn’t being moved in a valid way.

If you’re still stuck, show both objects and how you move them.

✅ How to format code on Discussions

Code is formatted by surrounding it with 3 backticks, and color coded as C# with cs or csharp:

// Your code here