Door animation bugs and stays open unity 3D
Well, I have this door code in unity. The door has one full animation, where it it opens, and closes. The code has it so, if you get into the trigger collider, it will animate until it's open, but when you leave, it completes said animation.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class DoorScript : MonoBehaviour {
Animator anim;
void Start () {
anim = GetComponent<Animator> ();
}
void Update () {
}
void OnTriggerEnter(Collider other)
{
anim.SetTrigger("OpenDoor");
}
void OnTriggerExit(Collider other)
{
anim.enabled = true;
anim.SetTrigger("DoorClosed");
}
void pauseAnimationEvent()
{
anim.enabled = false;
}
}
Yet, however, when I run trough the door, or I get close and then run far from it, it will animate to be open. And if I pass through the door again, it closes... but then it opens again!
I really could use some help here.
Your answer
Follow this Question
Related Questions
Animator Is Not A Playable Error. 1 Answer
Logic for a lot of animations 0 Answers
MobController 1 Answer
stickman animation 1 Answer
Death animation for enemy 0 Answers