- Home /
unwanted delay between animations
I am trying to transition from one animation to a second animation, but it seems that the transition is reading the variable fast enough. My first animation will play once, and waits until the condition is true to move onto the next animation. However, once I set the necessary bool to true, there is a slight delay when going into the next animation.
Here's some of the code that I'm using: public class bowLogic : MonoBehaviour { Animator ac;
int clickDown;
// Use this for initialization
void Start () {
ac = GetComponent<Animator> ();
clickDown = Animator.StringToHash ("clickDown");
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton (0)) {
ac.SetBool (clickDown, true);
}
if (Input.GetMouseButtonUp (0)) {
ac.SetBool (clickDown, false);
}
}
Once the mouse is held down I want it to transition to the second animation once the first one is done. The transition is instant when you hold down the mouse during the first animation, but if the first animation is done playing and is waiting on the last frame, clicking the button doesn't instantly transition but holding it for a few tenths of a second does.
$$anonymous$$y hypothesis is that even though the first animation isn't looping, there' still some internal timer that's looping and only at the end of the loop does the transition check if the bool is true. Not sure if I explained that right or if it makes sense but it's a shot.
$$anonymous$$aybe the problem lies with the exit time settings of the transitions?
Answer by iAmAwsum · Dec 05, 2016 at 03:04 PM
In the animator window select an arrow :
then in the inspector window make sure to untick "Has Exit Time", "Fixed Duration" and set "Transition Duration(%)" to 0, like so :
This prevents the animation from playing at all, it'll just be stuck on the first frame permanently.
Answer by Shrikky23 · Dec 05, 2016 at 03:53 PM
In the animator controller, select the transition and make the Transition duration 0.
Also there are chances that you are in a coroutine or it is waiting to finish the previous animation (uncheck has exit time in the previous animation, if you want instant change of animation)
Answer by unity_N7zkzSHCoLdMLg · Aug 31, 2020 at 10:33 PM
Just adding this for future searchers. Another reason could be the order your transitions are in. In the state drag the transition with higher priority up to the top.
This worked in my case. I was getting some rather ugly transitional behavior conditionally. You deserve a hero cookie... or at least an upvote.
Answer by Paricus · Dec 05, 2016 at 02:19 PM
have you checked exit times in the transitions on the animator controller?
I keep forgetting that exit time set to zero means no transition.