How to make a instant transition with Mecanim?

Hi, i have animations made one by one, with legacy i just need to call Play the animation states one by one. But with Mecanim, the transition always take time, how do i can make instant transition to switch animation clips?(I mean i don’t need blending with some animations)

Thanks!

There is a trick if you don’t like sliders. Go to the top right corner of the Inspector window and select Debug from the drop down menu (next to the lock). Now you can type in values.

Current Mecanim Version (Unity 4.3 and later)

You can simply use the Animator.Play() method in your scripts.

This method will instantly transition the animator into a different state, ignoring any blending or transitions you’ve set up.

The only drawback is that you need to specify the name of the target state in your scripts, so anyone working on the Mecanim animation state machine will have to be careful to also update the scripts when a state is renamed.


Early Mecanim Versions (before Unity 4.3)

In your Mecanim “Animator” (the thing where you design the animation state machine in), click on a transition between two states. The inspector will show you a panel in which you can tweak how the animations are blended together:

5329-blending.png

If you reduce the blending time to zero there, the animation will switch instantaneously. In my example above, that would mean moving the “Walk” animation all the way to the left and shrinking grey area behind the “Stand” animation (the blending phase) to a length of 0.

Does this not work for you?

Animator anim = GetComponent();

if(Input.GetKeyUp(KeyCode.W))
anim.CrossFade(“WalkUp”, 0f)

else if(Input.GetKey(KeyCode.S))
anim.CrossFade(“WalkDown”, 0f);

Manual: Unity - Scripting API: Animator.CrossFade

This should bypass transitions. I’m not sure if the current state and the one you specify for the CrossFade have to be connected through an AnyState, so you’ll have to try it and see. If not, I’d think you could have your “instant-on” states just orphaned in your Animator and just invoke them from script. Note that the state name is CaseSensitive.

Hope that helps.

I’ve read so many posts about this. Maybe they come up with an “Instant Transition” Option in the next Unity. Would be much, much, much better than fiddeling around with the sliders all the time…

Same problem here.
However, I`m still with a little delay between animations.

Untick “Has Exit Time” in the transition inspector.

I’m using Unity 5.3.3f, this worked for me.

Deselect “Has Exit Time” on the transition (arrow bit connecting two states/clips).
Figured that out after not wanting to do some of the suggested options above.

Problem with instant transitions is that they feel unnatural and appear bad.

In Unity 5 there is no more “Atomic” parameter, so what I found works best so far is to have a transition for example of 0.25 seconds but always select “Interruption Source / Next state”.

That way the next state can always interrupt the transition, so you have good appealing transitions but with all the responsiveness in the animations (i.e. not skipping animations because transition was still playing).

Using 3.5.6: the “atomic” option mentioned in comments is now a dropdown called “Interruption Source”. Set Interruption Source to “Next State”, and zero out the timers if needed.

Uncheck “atomic” to make it so an animation can transition out at any time (and will ignore exit time if there is one).

I totally agree.
I have the same effect with an animation that loops, with the first frame that sometimes pops up.

The workaround to avoid this first frame glitch is to make the animation say twice the length you need (duplicate the latest keyframe and put it at the right time) and use an Exit Time of 0.5.

Same here, for animations which control scripts for procedural things it is crucial, because even one or two frames inserts “error/noise”. There should be option to make instant transition, with no offset.

Even i was also facing the same problem.
In unity 5 please uncheck the “Has exit time” option.

When You select the transition between states, there is a box you need to uncheck called Has Exit Time. Uncheck that and your animations will transition immediately
@iiley

I had a similar problem (Unity 5.6.3) except that for me, I had Has Exit Time = true, Exit Time = 0, Transition Duration = 0, but it would still spend a full second in the state if I had no animation clip in there. I was able to drop the transition to a single frame by turning off Has Exit Time and instead adding a condition that checks a bool parameter that is always true.