- Home /
If multiple triggers activated
Hello I would like to know how to create a variable such as if more than one trigger is activated (or was activated) to go to a command, this is the script I was using but I am getting errors on it
var youwinGUI : GUITexture;
var player : GameObject;
function OnTriggerEnter(Collider){player, activated = true;}
Bool : a = Gobj1. GetComponent(Trigger).activated;
Bool : b = Gobj2. GetComponent(Trigger).activated;
Bool : c = Gobj3. GetComponent(Trigger).activated;
If (a&&b&&c){activated; youwinGUI.enabled = true;}
Thanks.
function OnTriggerEnter(Collider)
Your not na$$anonymous$$g the variable in the ()!
function OnTriggerEnter(Collider ) :)
Answer by xxBarginsxx · Jan 18, 2015 at 06:32 PM
You need to use void OnTriggerEnter with a Collider Array like this.
void OnTriggerEnter(Collider[] cols)
{
if (cols[0].tag == "TAG")
{
//Do Code
}
if (cols[1].tag == "TAG")
{
//Do Code
}
if (cols[2].tag == "TAG")
{
//Do Code
}
//And so one
}
This should return events for every Collider in the array the gets fired :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613180647im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
Displaying GUITexture after all triggers activated 0 Answers
Load texture from multiple sprite 1 Answer
how to cancel OnTriggerExit when already hitting a 2nd trigger 2 Answers
How do I call a script or a function to be active 'while'a GUITexture is displayed? 1 Answer