I have multiples of the same door and I would like to have the user open a door and keep the door open until the user close it manually again by pressing a key. The doors can only be opened via proximity and by pressing a key. However the problem lies in figuring out the logic so that the script stores a boolean varaible in the door or in proximity. I have tried to figure this ourt for several days now I can’t get past this block. Please help.
My triggers script looks like this:
var Door : GameObject;
var door_open : boolean = false;
static var door_boolean = null;
static var door_proximity : boolean = false;
static var the_door = null ;
function OnTriggerEnter() {
door_proximity = true;
the_door = Door;
door_boolean = door_open;
print (door_boolean);
//print (door_proximity);
}
and my player script looks like this:
function Update () {
//print (door_trigger.door_boolean);
//print (door_trigger.door_proximity);
if (door_trigger.door_boolean == false) {
if (Input.GetKeyDown (KeyCode.Tab) (door_trigger.door_proximity == true)) {
door_trigger.the_door.animation.Play("doorOpen");
door_trigger.door_boolean = true;
}
}
else if (door_trigger.door_boolean) {
if (Input.GetKeyDown (KeyCode.Tab) (door_trigger.door_proximity == true)) {
door_trigger.the_door.animation.Play("doorClose");
door_trigger.door_boolean = false;
audio.PlayOneShot(hitClip);
}
}
}
thank you very much in advance