How to play animation immediately in Mecanim (akin to legacy StopAllSameLayer)

I’ve been tearing my head out ever since I ported my legacy animation setup to Mecanim…

I have several layers, and I want to be able to immediately play an animation on an event. I’ve tried triggering the transition for Any state with a bool and a trigger, but it never transitions immediately, always waits for the looping animation to finish then it transitions.

Is there anyway to call “stop all same layer” mecanim? Or a simple workaround?

If you want to play inmediately a state from another, the transition between both, have to unchecked the has exit time box, and put the Transition Duration to 0.

If you want to play inmediatly a state withouth a transition, you have to put:

private Animator animator_attached;

void Start(){
  animator_attached = this.gameObject.GetComponent<Animator>();

  public void My_Method(){
   this.animator_attached.Play ("Name_Of_State_I_Want",position_in_layer,time_delayed);
}
}

I hope this help you

1 Like