Question by
rose_among_thornes · Jul 11, 2016 at 10:05 PM ·
scripting problemnot working
Door open with Key script isn't working
I don't know if i'm being ridiculously stupid, but I'm normally a concept artist, I'm trying to make a door open with a key and quite honestly have no idea why it isn't working. The script is:
@HideInInspector
public var Pressed : boolean = false;
@HideInInspector
var isOpen : boolean = false;
class DoorTextClass {
var DoorLockedText : String = "The Door is Locked find Key";
var DoorJammedText : String = "The Door is Jammed";
}
var DoorText ; DoorTextClass = new DoorTextClass ( ) ;
function WaitPressed() {
if(Pressed == true){
yield WaitForSeconds(2);
Pressed = false;
}
}
function OnGUI(){
if(Pressed && isLocked == true && isJammed == false)
{
GUI.Label(Rect(Screen.width /2 -62.5, Screen.height /2 + 50, 200, 100), DoorText.DoorLockedText);
WaitPressed();
}
if(Pressed && isJammed == true && isLocked == false)
{
GUI.Label(Rect(Screen.width /2 -62.5, Screen.height /2 + 50, 200, 100), DoorText.DoorJammedText);
WaitPressed();
}
}
Any help is much appreciated :)
Comment