Search Unity

2 Coliders on an Asset

Discussion in 'Getting Started' started by larswik, Oct 12, 2015.

  1. larswik

    larswik

    Joined:
    Dec 20, 2012
    Posts:
    312
    I am now working on script for my Zombie to attract the player. I have doors that are triggered to open with the player or zombie cross the collider on the door, that has the trigger checked off.

    My zombie has the standard capsule collider and ridgidbody attached. I added a second spherical collider to the zombie and selected the trigger check box for this second collider I attached to it. This is the trigger that I want to use when it comes into contact with the player.

    Am I able to name the colliders to identify them in script? So a specific trigger Collider can be checked to see if it has collided with the player, and not the collider that is used for the ridgidbody?

    I hope I am making sense here?
     
  2. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    The capsule collider isn't a trigger is it? When I've done this (not often) I have a collider on the player for hits & movement & a trigger collider for larger things like detecting the other player or enemy etc. I don't need to differentiate as one works using ontrigger & the other works with oncollision
     
  3. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Expounding on what ted sed:

    Triggers and collision colliders are treated separately. Use OnTriggerEnter for your spherical trigger collider and OnCollisionEnter for the capsule.
     
  4. larswik

    larswik

    Joined:
    Dec 20, 2012
    Posts:
    312
    I see what you guys are saying, thanks. So I will test it but if I understand you 100% any colliders that have the Trigger check box checked, will not trigger other triggers?
     
  5. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Correct. Triggers are only triggered by non-trigger colliders.