- Home /
Delay on animation
hello there i have a problem with my animations, it dont work as i want. in my game i have 3 drawers and i want to open 1 and close the other 2. i checked out has exit time and set all durations at 0 already.
the problem is, when i open one of the drawers, it is random between something like 0 and 1 second until it opens.
sometimes it opens exactly when i press it (this is how i want it) and most of the time it needs some time until it reacts..
here is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Schublade : MonoBehaviour {
private bool isOpen = false;
public GameObject Schublade1;
public GameObject Schublade2;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerStay(Collider collision)
{
if(collision.gameObject.tag == "Player" && Input.GetKeyDown(KeyCode.Joystick1Button1))
{
StartCoroutine("Closing");
}
}
IEnumerator Closing()
{
Schublade1.GetComponent<Animator>().SetBool("isOpen", false);
Schublade2.GetComponent<Animator>().SetBool("isOpen", false);
yield return new WaitForSeconds(1f);
GetComponent<Animator>().SetBool("isOpen", true);
}
}
Your answer

Follow this Question
Related Questions
Time Delay Animation 1 Answer
How do I put a delay in this? 2 Answers
How to Let an Animation Finish Before Playing Another? 1 Answer
Re-positioning objects after animation done playing? 1 Answer
Delay Invisibility 2 Answers