-
I have a panel that is child of canvas
-
use the panel to instantiate some gameobject (cards)
-
these are visible on canvas but not on main camera
-
Another gameobject (enemy) is not attach to canvas but is instantiated in their given position
-
this is not visible on canvas but is visible on main camera
-
I am trying to collide both gameobjects (cards and enemy) with OnTriggerEnter2D but it does not collide
-
the card has a rigidbody2d and a box collider with isTrigger checked
-
the enemy just has a box collider (isTrigger unchecked)
-
the code is on the card:
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == “Enemy”)
{
print(“collided”);
}
}
- is there anyway to collide both gameobjects?