Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Is there any way to know which trigger have been activated?(If I have more colliders)

Discussion in 'Scripting' started by Like-A-Sir, Feb 4, 2016.

  1. Like-A-Sir

    Like-A-Sir

    Joined:
    Sep 14, 2015
    Posts:
    33
    Good day!

    I have more collider which are triggers on an enemy.Can I know exactly what trigger have been activated?(In 1 script).
     
  2. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    do you mean that you have attached several trigger colliders to a game object?
     
  3. Like-A-Sir

    Like-A-Sir

    Joined:
    Sep 14, 2015
    Posts:
    33
    no
    Yes.I mean,there are also child game objects who are colliders working as triggers.
     
  4. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    For the triggers which have been put on the parent object, no.

    For the child objects, if you put a script on it specifically to detect trigger events, yes. The detection for those seem to be individual, although it MUST be the script on the child object reporting its hit, or trigger event, to the parent object.
     
  5. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    I think what will be more helpful is telling us what you intend to achieve
     
  6. Like-A-Sir

    Like-A-Sir

    Joined:
    Sep 14, 2015
    Posts:
    33
    My game object is an enemy,and it has I long trigger to detect if the player is beside him,and a little trigger in front of him,which tells him when the player is close to him and it has to attack.When the long trigger is activated , the enemy has to run towards the player,and when the player triggers the closer trigger the enemy stops and attack.
     
  7. Like-A-Sir

    Like-A-Sir

    Joined:
    Sep 14, 2015
    Posts:
    33
    I already solved the problem by creating separate scripts for every collider.Thank you very much for your interest.Have a nice day sir!