- Home /
Door animation bugs and stays open unity 3D
Hi, I'm creating a game where I have a door. Said door has only one animation for opening/closing. I have a script that, when the player gets close to the door, the animation will run until it stops in the middle, when it's open. When the player leaves, the door continues it's animation, and closes.
However, if I go running through the door, it bugs, and keeps open most of the time. If I go through it again, then the door closes... and inmediatly opens again! I really need help here.
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;
}
}
Your answer
Follow this Question
Related Questions
Issue with mecanim playing an animation using setbool 1 Answer
Hello! I have some issues with animations. 1 Answer
Efficient way to instantiate a sprite that plays an animation then destroys itself? (3d space) 1 Answer
My animations are messed up 1 Answer
Is there a new retargetting system for the animation in 5.5? 1 Answer