Two Collider on the same Object! [Unity 5.5]

Hi all! It’s me again.

I’m currently working on an isometric aRpg.

I currently have 2 collider on my enemies. One of them is a collider for collision, and is fitting the enemy size. The other one is a trigger, and is used to detect player click so the enemy is easier to select.

My issue is I just added an attack that use collider to trigger it’s damage.

I attack, and I damage everything that enter my trigger. I keep a temporary list with every instanceID I touch, so My attack won’t affect twice the same enemy.

I remembered that I had 2 collider on the enemy, and both of them retourn a different instanceID. Also, I don’t wantr to hit the bigger one, only the smaller collider.

Is there a way to do this? How can you handle 2 different size of trigger?

Thank you!

If both colliders are on the same gameobject, you might be able to check the size of the collider itself to see if it’s smaller than a certain amount and then deal damage.

Another option may be to move a collider to a empty gameobject and make that a child of the enemy, thus you could just compare the colliders gameobject name and deal damage if it matches the correct “damage collider” name.

Just some thoughts.

2 Likes

You 2nd solution, That sound pretty good. I actualy used that in another game, but didn’t think about that way.

The first solution might be hardr to implement as my radius/size could change.

But having a collider in a child gameobject could works.

Thank you!