Everything but the animation is working, when I press E to open the door it opens than closes on its own any help?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Door : MonoBehaviour
{
// Start is called before the first frame update
public GameObject OpenText;
public bool InZone;
public Animator dooranim;
void OpenDoor()
{
dooranim.SetBool("Opened", true);
}
void CloseDoor()
{
dooranim.SetBool("Opened", false);
}
private void OnCollisionEnter(Collision collider)
{
if (collider.gameObject.CompareTag("Sensor"))
{
InZone = true;
OpenText.SetActive(true);
}
}
private void OnCollisionExit(Collision collider)
{
if (collider.gameObject.CompareTag("Sensor"))
{
InZone = false;
OpenText.SetActive(false);
}
}
void Start()
{
InZone = false;
}
void Update()
{
if (Input.GetButtonDown("Sensory") && InZone)
{
OpenDoor();
}
else
{
CloseDoor();
}
}
}