Unlocking doors

ok so i have this security door i want to open * when i pick up an object, such as a key* so you go find the key pick it up, which i have done, THEN when you go up to the door it will open. how could i do this, maybe
//search player for the key

There are a few ways to do this. One is with a boolean. If the door is locked then the boolean is false, but when the key is picked up true and the door can be unLocked. :smile:

do you have an example script? im not very good. but thanks for the reply i’'l give it a go.

On your door code. Create a Static Bool.

atatic var canOpen : boolean;

Wrap the animation line with the if condiiton.

if(canOpen==true){
//animation Code
}

Then On you key

function OnMouseDown() {
  Destroy (gameObject);
  doorScriptName.canOpen==true;
}

These are just examples to write your own script. Cause i dont know exactly what you got going on in your game. But in a nut shell the door will not open till the condition is met. Once you close the door you can then decide if you want the bool to remain open(u still have the key) Or u now have to get a new key and set the bool back to false. :smile: