Search Unity

Multiple Collider in one GameObject : how tho know which one has just triggered ?

Discussion in 'Scripting' started by bali33, Aug 29, 2014.

  1. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Hi guys,

    I have a character which plays different animations depending which part (head, torso, arms etc.) has been clicked. At first I thought to add multiple Colliders into my character root GameObject, but then I realized that I won't be able to know which collider just triggered. I didn't see any way to differentiate (name or whatever) a Collider from another Collider.

    Is there a way to do that ? I really would like to avoid creating one child GameObject with Collider for each part of the character, I mean, if it's possible ;-)

    Thank you
     
  2. FlaSh-G

    FlaSh-G

    Joined:
    Apr 21, 2010
    Posts:
    212
    When you play animations, you already have a GameObject for every part of the character. Adding colliders to them lets you even have them positioned correctly while an animation is playing.