Question regarding OnTriggerExit2D

Hey all,

So when we added the box collider to the enemy, to check when the enemy has to flip, in the case where the enemy hits a wall, why does the OnTriggerExit2D works? is’t the walls and ground have the same collider?

So if the enemy was on a floating platform for example, this makes sense, because the box collider will exit the platform’s collider and trigger the OnTriggerExit2D method. But why does the method work when there is a wall?


Hi Waleed,

Seems this question has slipped though the net
Is this still an issue?

Hi Waleed,

Does Bence’s explanation answer your question?

1 Like

Hey, actually you will notice that if you put the player in front of the enemy then enemy will not flip his face, because onExitTrigger not triggered unless you get the player away, then enemy will flip, so, as a result i think the issue is related to the composite collider attached to foreground, i think that especially this type of colliders treated in different way as a line or something, because when enemy’s box collider crosses the facing line of composite collider, then OnTriggerExit is called directly, maybe experts here will help us in more understanding


Yes, thanks

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms