yeah like you see in the Q titel i need to change the script a little.
now the behaviour on the door is F to open and then the door closes by himself so how do i change this so when i open it then it gonna be still open until I press F again to close it.
(easier said, that I do not want that door closes automatiskt, for I have to close the door on the same key-(F)
but atfer then I want to put in so the door closes aoutomatiskt
for we say that when a player opens a door and leave it open and run away, then I want that door to close automatically, we say after 1h. or the player can stay there and wait 1h and the door close, he actually don’t need to run away but you get the point
Script:
#pragma strict
var theDoor : Transform;
private var drawGUI = false;
private var doorIsClosed = true;
function Update ()
{
if (drawGUI == true && Input.GetKeyDown(KeyCode.F))
{
changeDoorState();
}
}
function OnTriggerEnter (theCollider : Collider)
{
if (theCollider.tag == "Player")
{
drawGUI = true;
}
}
function OnTriggerExit (theCollider : Collider)
{
if (theCollider.tag == "Player")
{
drawGUI = false;
}
}
function OnGUI ()
{
if (drawGUI == true)
{
GUI.Box (Rect (Screen.width*0.5-51, 200, 102, 22), "Press F to open");
}
}
function changeDoorState ()
{
if (doorIsClosed == true)
{
theDoor.animation.CrossFade("Open");
//theDoor.audio.PlayOneShot();
doorIsClosed = false;
theDoor.animation.CrossFade("Close");
//theDoor.audio.Play();
doorIsClosed = true;
}
}
ThX in advance