Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
62
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.        openDoor();
  17.        isDoorOpen = true;
  18.     }
  19. }
  20.  
  21. if(Physics.Raycast(transform.position, transform.forward, hit, 2))
  22. {
  23.     if(hit.collider.gameObject.tag == "player" )
  24.   {
  25.     if (Input.GetKeyDown ("a"))
  26.    {
  27.       door.activateDoor();
  28.     }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement