Mecanim CrossFade transition interruption issue

Imagine that you have a idle state running and you have a run forward state. So, if you press W you trigger a transition from idle to run forward with CrossFade and if you stop pressing W you trigger a transition from run forward to idle.

Here comes the problem, the transition takes X time to complete, if you only push W once the character should stop the transition and come back to the idle state, but Mecanim thinks that he’s still in idle because the transition didn’t finished to go from one state to the next.

So, how I’m supposed to make a responsive movement system through CrossFade if you can’t abort a transition when you desire to?

So, you can’t come back to the origin state when you are CrossFading to the next because Mecanim believes that you are still on the origin state when, visually, you are not (you are between the two).

Is this a bug, or a desired behavior? If it’s a bug, is this gonna be fixed some time soon? If it’s the desired behavior, I’m not supposed to use CrossFade in that way?

Thanks.

EDIT1: This is an example of what I want to achieve → - YouTube

EDIT2: I’m attaching a clear example of the problem: Mecanim CrossFade Problem

Press W to trigger an Animator.CrossFade from Idle to Walk Forward, you’ll that if you press it only once it will keep walking forward until the transition is finished, so you CAN’T interrupt the transition to come back to the origin state until the transition is ended (Idle in this case).

Also, if you press F you’ll triger a manual CrossFade to Idle, and, as you can see it won’t work until the Idle to Run Forward transition is ended. This is just to make the problem more clear.

So, the thing is that it seems it’s impossible to do this through scripting with CrossFade, ok.

So, the solution is to use Blend Trees so you can control the “transitions” manually through scripting with full control with one or two variables. I have used a 2D Freeform Directional Blend Tree because I need multiple speeds in multiple directions, but you should use whichever fits your problem better.

EDIT: As pointed out by gelu23, it’s in fact possible to do this through CrossFade by explicitly setting the normalizedTime to 0.

So… if you want to use a state-machine go for Blend Trees and if you want to use CrossFade use normalizedTime 0.

You should mark your transition as “Interruption Source: Next State”.
This way, the transition could be interrupted by trantisitons of the next state (run forward).

Waaaay late to the party here, 8yrs, so might not be relevant BUT I cached the current state (on the 3rd layer), called rebind, then used animator.play to force the character into the animation they were just in with the normalized time value for the cached sate.

	void RebindAndRestoreAnimator()
	{
		// Cache info
		Animator anim = PlayerInfo.playerAnim;
		AnimatorStateInfo info = anim.GetCurrentAnimatorStateInfo(3);
		// Rebind then resetinfo
		anim.Rebind();
		anim.Play(info.shortNameHash, 3, info.normalizedTime);
	}