- Home /
Question by
rosenking · Mar 28, 2017 at 05:26 PM ·
animationcolliderstriggering animation box collider
animation plays once multiple colliders are placed?
I want an animation to play once the player places 3 gameObjects (Key_01, Key_02, Key_03) within the space of the animated object's collider box.
I have this code so far:
void OnTriggerEnter(Collider col)
{
if (transform.GetComponent<Collider>().isTrigger == true && col.gameObject.name == "Key_01")
{
transform.GetComponent<Animation>().Play ();
transform.GetComponent<Collider>().isTrigger = false;
}
}
This code works only for "Key_01" to trigger the animation, and when I duplicated the script and changed the line to say "Key_02" and added the script to the animated object as well, Key_01 or Key_02 triggers the animation (instead of waiting for both game objects to be present before playing the animation).
Is there a way I could add on to this script to make it so the animation plays once all 3 gameObjects are present?
Comment