I have the following code:
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.tag == "MainCamera")
{
Debug.Log("caughtCam");
}
if(collision.gameObject.tag == "Player")
{
Debug.Log("caughtPlayer");
}
GeneralCollisionDetection(collision.gameObject);
}
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!