How can I play an animation when 3 triggers are being detected on character ??

Hi all .

I need a code to be able to play an animation of an object only when 2 or more specified triggers are colliding with Character.

The code im using to play animation is this one

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

var ObjectToAnimate : GameObject; //Implement your Faller game object into this variable in the inspector

function OnTriggerEnter (Other : Collider){

if(Other.gameObject.tag == “Player”){

ObjectToAnimate.animation.Play(“DoorOpen_IN”);

}

}

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Basically I need something like If TriggerA, TriggerB, TriggerC, Play Animation, or however its done.

If someone has done some thing similar and can help that would be awsom if not, I will just take longer :smile:

You could set up 3 booleans, one to represent each trigger. When all three booleans are true play the sound

thx, looking for booleans_ cant deam to find reference on what they are, just code with them, any script documentation in unity page ?

Booleans are a variable type that hold true/false values.

http://en.wikipedia.org/wiki/Boolean_data_type

Example.

public bool animationTrigger = true

....

if (animationTrigger == true){
Animation.play(WalkingAnimation);
}

In your case you just need to create 3 boolean variables and set them to “true” OnTriggerEnter or OnTriggerStay, and set to false on OnTriggerExit. Then check whatever the boolans are true or not.

something like:

public bool animationTrigger1 = false;
public bool animationTrigger2 = false;
public bool animationTrigger3 = false;



...
if (animationTrigger1 == true && animationTrigger2 == true && animationTrigger3 == true){
ObjectToAnimate.animation.Play("DoorOpen_IN");
}

and on the collider something like

void OnTriggerStay (Other  Collider){

if(Other.gameObject.tag == "Player"){

//turn trigger value to true
Player.animationTrigger1 = true;

}

}

void OnTriggerExit (Other  Collider){

if(Other.gameObject.tag == "Player"){

//turn trigger value to false
Player.animationTrigger1 = false;

}

}

This is sample code, you need to create the final script yourself.

Kind regards.

Thx thats more like it, I will give it a try. sorry for Noobnes, game is not so noobish :smile: