Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var isDoorOpen = false;
  2. var door = gameObject.FindWithTag("pintu");
  3. var hit : RaycastHit;
  4.  
  5. //Declare functions
  6. function openDoor{
  7.     door.animation.Play("Buka");
  8. }
  9.  
  10. function closeDoor{
  11.     door.animation.Play("Tutup");
  12. }
  13.  
  14. function activateDoor(){
  15.     if(isDoorOpen){
  16.        closeDoor();
  17.        isDoorOpen = false;
  18.     } else {
  19.        openDoor();
  20.        isDoorOpen = true;
  21.     }
  22. }
  23.  
  24. if(Physics.Raycast(transform.position, transform.forward, hit, 2))
  25. {
  26.     if(hit.collider.gameObject.tag == "player" )
  27.   {
  28.     if (Input.GetKeyDown ("a"))
  29.    {
  30.       door.activateDoor();
  31.     }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement