Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ourDoor : Transform;
- private var drawGUI = false;
- private var doorClosed = true;
- function Update ()
- {
- if(drawGUI == true && Input.GetKeyDown(KeyCode.E))
- {
- 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), "[E] To Open");
- }
- }
- function changeDoorState()
- {
- if(doorClosed == true)
- {
- ourDoor.GetComponent.<Animation>().CrossFade("SlidingDoor");
- ourDoor.GetComponent.<AudioSource>().Play;
- doorClosed = false;
- yield WaitForSeconds(5);
- ourDoor.GetComponent.<Animation>().CrossFade("SlidingDoorClose");
- ourDoor.GetComponent.<AudioSource>().Play;
- doorClosed = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement