How to stop mecanim transition
Hi guys,
When my character lands on the ground after a jump I'm using animator.Play command to fire the "land" animation. Most of the times works fine, excepting when my character is in the middle of a transition. If that happens, animator.Play command doesn't work instantly, but waits to finish the transition first.
I'm unable to find any command that forces the transition to be stopped. Does anyone know if it exists or if there's a way to avoid waiting for it to finish?
Thanks
Answer by GatoOfTheNight · May 13, 2017 at 06:10 PM
Well, I need that transition to have the "has exit time" property checked to work properly.
The thing is, is there any way to interrupt by code a "has exit time" transition in order to play a different animation?
Answer by theANMATOR2b · May 13, 2017 at 10:57 PM
I'm not a code guy - just an animator, so feedback might be only half relevant.
The 'has exit time' option allows transitions to be locked so they are not interrupted OR allows them to also 'be' interruptible - so this is the answer you seek, however I'm not sure what code snippit is needed. Maybe this?
https://docs.unity3d.com/ScriptReference/Animations.AnimatorStateTransition-hasExitTime.html
https://docs.unity3d.com/ScriptReference/Animations.AnimatorStateTransition-exitTime.html
Alternately - consider what transition is happening when the character should be landing.
Isn't the character performing a falling animation before he should be transitioning into landing?
What transition is the character 'sometimes' in when the landing animation 'should' be triggering? Maybe there is an alternate setup which removes the possibility of any transitions happening when the character should be landing.
Your answer

Follow this Question
Related Questions
Changing the idle animation in a mecanim without making whole new state machine. 1 Answer
is it possible to have a mechanim condition to compare two variables? 0 Answers
Transition Between Animations Delay 0 Answers
Can't jump while running, and animation won't transition 0 Answers
Moving a player character that has ragdoll colliders/rigidbodies 0 Answers