I am creating a system that the player must click on a sequence of buttons to turn on a machine. Each time he clicks a button, plays an animation of the object and one light is lit. The problem is that the second time on the player passes through the button, the program warns that cannot add other component. Any way to fix it? Thanks.
var a = false;
var b = false;
var c = false;
if (hit.gameObject.tag == "bt1" && a == false) {
a = true;
var bhit1 : GameObject = GameObject.FindWithTag("bt1");
bhit1.animation.Play ("anim1");
bhit1.AddComponent(Light);
}
if (hit.gameObject.tag == "bt2" && b == false) {
b = true;
var bhit2 : GameObject = GameObject.FindWithTag("bt2");
bhit2.animation.Play ("anim2");
bhit2.AddComponent(Light);
}
if (hit.gameObject.tag == "bt3" && c == false) {
c = true;
var bhit3 : GameObject = GameObject.FindWithTag("bt3");
bhit3.animation.Play ("anim3");
bhit3.AddComponent(Light);
}