I’m using an OnTriggerStay2D()
function that does something while an object in inside the collider (doesn’t matter what). However, sometimes I have another, so a total of 2 colliders that may stay inside that collider. The two colliders are not on the same Game Object
. I’m trying like this:
void OnTriggerStay2D(Collider2D other)
{
if (other.gameObject.CompareTag("Obj1"))
{
//do something
}
if (other.gameObject.CompareTag("Obj2"))
{
//do something else
}
}
but do something else just never happens when Obj1
is already inside. How to make a collider sense two colliders at once for OnTriggerStay2D()
?