banner
banner

Reputation: 79

Unity trigger detect if player is completely out of collider

I use OnTriggerEnter and OnTriggerExit to simulate ladders. When i climb up a ladder the OnTriggerExit is fireing as soon as the top of the player collider is outside of the ladder collider while the bootom of the plyer collider is still inside of it. The same when climbing down, the OnTriggerExit fires as soon as the bottom of the player collider is out of the ladder collider while the rest is still inside. Can i (and how) detect if the colliders bottom or top is completely out of the ladder collider and not only starts to get out?

Upvotes: 0

Views: 865

Answers (1)

sommmen
sommmen

Reputation: 7618

We would need more info like some code or at the very least some screenshots of your setup, However i think you can tackle this 2 ways:

Instead of seperate triggers for each body part, instead create one big one.

Or you could chain your triggers together. In this case each trigger should call the parent component, and increment an integer (int TotalAmountOfCollidersTriggered = 0) in onTriggerExit you decrease this value. Then when the value is positive, you know one of your colliders triggers something, and when the value is 0 you know that no collider is triggered anywhere.

Upvotes: 0

Related Questions