Active object when all the tags are in the collider
Hi i want to do this ;
I made a script but it doesn't work ( and i replace the && for || (or) and still not working) i want to the collider reacts (and appears a Gameobject) When all the tags are into it
var activeObjects : GameObject;
function Start()
{
activeObjects.SetActiveRecursively(false);
}
function OnTriggerEnter(other : Collider)
{
if(other.gameObject.tag == "A" && other.gameObject.tag == "B" && other.gameObject.tag == "C")
{
activeObjects.SetActiveRecursively(true);
}
}
function OnTriggerExit(other : Collider)
{
if(other.gameObject.tag == "A" && other.gameObject.tag == "B" && other.gameObject.tag == "C")
{
activeObjects.SetActiveRecursively(true);
}
}
Thanks!
sin-titulo.jpg
(44.1 kB)
Comment
Best Answer
Answer by Positive7 · Sep 09, 2015 at 11:06 PM
#pragma strict
var activeObjects : GameObject;
var a : boolean;
var b : boolean;
var c : boolean;
function Start(){
activeObjects.SetActive(false);
}
function OnTriggerEnter(other : Collider){
if(other.gameObject.tag == "A")
{
a = true;
}
if(other.gameObject.tag == "B")
{
b = true;
}
if(other.gameObject.tag == "C")
{
c = true;
}
}
function OnTriggerExit(other : Collider){
if(other.gameObject.tag == "A")
{
a = false;
}
if(other.gameObject.tag == "B")
{
b = false;
}
if(other.gameObject.tag == "C")
{
c = false;
}
}
function Update(){
if(a && b && c){
activeObjects.SetActive(true);
}else{
activeObjects.SetActive(false);
}
}
Your answer
Follow this Question
Related Questions
OnTriggerEnter 2 Answers
Player should be able to go through Wall 3 Answers
Collisions not happening 0 Answers