Advertisement
Guest User

Untitled

a guest
May 14th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1.  
  2. var ourDoor : Transform;
  3. private var drawGUI = false;
  4. private var doorClosed = true;
  5.  
  6. function Update ()
  7. {
  8. if(drawGUI == true && Input.GetKeyDown(KeyCode.E))
  9. {
  10. changeDoorState();
  11. }
  12. }
  13.  
  14. function OnTriggerEnter(theCollider : Collider)
  15. {
  16. if(theCollider.tag == "Player")
  17. {
  18. drawGUI = true;
  19. }
  20. }
  21.  
  22. function OnTriggerExit(theCollider : Collider)
  23. {
  24. if(theCollider.tag == "Player")
  25. {
  26. drawGUI = false;
  27. }
  28. }
  29.  
  30. function OnGUI()
  31. {
  32. if(drawGUI == true)
  33. {
  34. GUI.Box(Rect (Screen.width*0.5-51, 200, 102, 22), "[E] To Open");
  35. }
  36. }
  37.  
  38. function changeDoorState()
  39. {
  40. if(doorClosed == true)
  41. {
  42. ourDoor.GetComponent.<Animation>().CrossFade("SlidingDoor");
  43. ourDoor.GetComponent.<AudioSource>().Play;
  44. doorClosed = false;
  45. yield WaitForSeconds(5);
  46. ourDoor.GetComponent.<Animation>().CrossFade("SlidingDoorClose");
  47. ourDoor.GetComponent.<AudioSource>().Play;
  48. doorClosed = true;
  49.  
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement