I have it setup so that I have 3 sets of 2 switches for each door (3) in my project. Everything was going well until I tested the switches out. All the doors in my program open simultaneously and that is not what I want. I want them to open individually. Below I have two javascript files for this. ObjectSetupSystem (On the Player Controller) is to setup the system of switches and Object Switch Object is for the switches themselves. My goal, again, is to have all the doors open individually other than all together.
1st FILE - ObjectSwitchSystem
enter code here//###########################PressureSwitch 1#######################
var switch1Name = "Pressure Pad1";
var switch1Bool : boolean = false;
var switch1 : GameObject;
//###########################DoorSwitch 1#######################
var switch2Name = "Wall Switch1";
var switch2Bool : boolean = false;
var switch2 : GameObject;
//###########################PressureSwitch 2#######################
var switch3Name = "Pressure Pad2";
var switch3Bool : boolean = false;
var switch3 : GameObject;
//###########################DoorSwitch 2#######################
var switch4Name = "Wall Switch2";
var switch4Bool : boolean = false;
var switch4 : GameObject;
//###########################PressureSwitch 4#######################
var switch5Name = "Pressure Pad3";
var switch5Bool : boolean = false;
var switch5 : GameObject;
//###########################DoorSwitch 3#######################
var switch6Name = "Wall Switch3";
var switch6Bool : boolean = false;
var switch6 : GameObject;
//############################DOOR SWITCH 1/2###################
var door1Bool : boolean = false;
var door1 : GameObject;
//############################DOOR SWITCH 3/4 ###################
var door2Bool : boolean = false;
var door2 : GameObject;
//############################DOOR SWITCH 5/6 ###################
var door3Bool : boolean = false;
var door3 : GameObject;
function Update () {
if(switch1Bool == true) {
if(switch2Bool == true) {
door1Bool = true;
door1.gameObject.transform.Translate(Vector3.up * Time.deltaTime);
}
}
if(switch3Bool == true) {
if(switch4Bool == true) {
door2Bool = true;
door2.gameObject.transform.Translate(Vector3.up * Time.deltaTime);
}
}
if(switch5Bool == true) {
if(switch6Bool == true) {
door3Bool = true;
door3.gameObject.transform.Translate(Vector3.up * Time.deltaTime);
}
}
}
2nd File - Object Switch (For the buttons themselves)
var Player : GameObject;
var bullet : GameObject;
function OnTriggerEnter(other : Collider) {
if(Player.tag == "Player") {
Player.GetComponent(ObjectSwitchSystem).switch1Bool = true;
Player.GetComponent(ObjectSwitchSystem).switch3Bool = true;
Player.GetComponent(ObjectSwitchSystem).switch5Bool = true;
Debug.Log("Activated PressureSwitch");
}
if(bullet.collider.tag == "Bullet") {
Player.GetComponent(ObjectSwitchSystem).switch2Bool = true;
Player.GetComponent(ObjectSwitchSystem).switch4Bool = true;
Player.GetComponent(ObjectSwitchSystem).switch6Bool = true;
Debug.Log("Activated Wall Switch");
}
}