How to select a specific collider of many on a gameobject?
I have an AI with 3 colliders.
On the AI's body only.
10 units around the AI
20 units around the AI
I have a player that shoots the AI to reduce it's health. The problem is when the player shoots the AI it registers the hits on the outer collider first (3).
Is there a way to identify what collider I want the raycast to use to register a hit?
Thanks in advance.
Answer by JusSumGuy · May 24, 2018 at 01:00 PM
You can make child object to hold each collider and tag each child object with a different tag. So the shot can check for the certain tag and ignore the other colliders. Or you can make a count variable and make a script that adds one to count each time the shot hits a collider. And when the count variable equals 2(meaning its the third collider its hit: 0, 1, 2) then do damage.