- Home /
 
 
               Question by 
               ryanhorbal · Jan 16, 2015 at 04:17 PM · 
                animationdooropenclose  
              
 
              Door will not open with the press of a button
This has probably been answered on here a thousand times but I cant find anything that helps my situation. I am trying to make a door that opens when you press E. I have followed the tutorial perfectly and still nothing will work. I have my 4 animations (DoorOpen, DoorOpened, DoorClose, and DoorClosed) I have the box collider around the door as a trigger. Any ideas?
  //The Base Door script will allow functionality for any kind of door
  //When the PLAYER enters a Trigger Volume, and presses the INTERACT key,
  //the door will change states (open>close, close>open)
  
  
  Animator anim;
  public GameObject hinge;
  
  // Use this for initialization
  void Start () {
  
      anim = hinge.GetComponent<Animator>();
  
  }
  
  // Update is called once per frame
  void Update () {
  
      if(anim.GetCurrentAnimatorStateInfo(0).IsName("DoorOpen") || anim.GetCurrentAnimatorStateInfo(0).IsName("DoorClose")) 
      {
          anim.SetBool ("DoorInteract", false);
      }
  }
  
  void onTriggerStay(Collider other)
  {
      if (other.tag == "Player")
      {
          if (Input.GetKey(KeyCode.E))
          {
              anim.SetBool ("DoorInteract", true);
          }
      }
  }
  
 
              
               Comment
              
 
               
              Ok Thanks. I just posted it with the 101/0101 button but I do not see a difference. What exactly does it do?
Your answer
 
             Follow this Question
Related Questions
open and close door 0 Answers
How to open a door with the "E" key 1 Answer
Closing sliding door Raycasting 1 Answer
Door Animation Setup 2 Answers
Open Door Via Trigger Collider 0 Answers