Multiple Triggers

Hey Guys,

this is probably a very easy one. I am making a jump and run and like in the Mario Game is want my Player to be able to kill enemies when he jumps on them. To achieve this, I made a triggerBox at the bottom of my character, the feetTrigger.
I use the OnTriggerEnter(Collider other) function. If the object which enters the feetTrigger has the tag “Enemy” the Object gets destroyed. That works so far.
My problem is, that I have a second trigger for the rest of my Players body, the bodyTrigger. This trigger also uses the OnEnterTrigger(Collider other) function to detect enemies. If an enemy enters this Trigger the Player looses one live. The Triggers don’t overlape, but sometimes an enemy enters both trigger at the same time.
The consequence is, the player looses a live and still kills the enemy. Anybody an idea how to avoid that?

Cheers Pascal

Hello Pascal,

you can solve this by adding a simple “boolean” trigger. All you will have to do is in your “OnTriggerEnter(Collider other) function” check the body collision first and if it did happen block the “Feet” collision checking part in the code in this way if the players body got hit first then the the “Feet” collider part won’t trigger. Also remember you need to size the players colliders properly so that at any given time only one will happen before the other.

hope this helps.

Raviraj.

Thx. That sovled my problem :slight_smile: