- Home /
Mecanim - transition from run to jump
I'm trying to have the character transition from run to jump when the jump button is pressed but it often doesn't transition to the jump animation. It instead continues to play the run animation while in the air.
If anyone can tell me why this is happening that would be great or if there is a better way of doing this.
This is the whole Layer
This is the transition from run to jump
Does this only happen when you try to transition from Run to Jump or does this "bug" also happen when you try to transition to the other jumps?
Also make sure that "Jump" is actually true
when you "Jump"
I get the same result for walking and Jump is true every time Jump is pressed.
Could it be that your jump is only true "as long as" jump is pressed? $$anonymous$$eaning it's related to the "key" and not the acctual character?
Perhaps you should heck wether the character is on the gound ins$$anonymous$$d :)
Answer by JonK · Aug 12, 2013 at 04:39 AM
I was checking this way
bool grounded = CM.IsGrounded;
anim.SetBool("isGrounded", grounded);
if(grounded)
anim.SetBool("Jump", false);
anim.SetBool("Falling", CM.Falling);
if(CM.Falling)
anim.SetBool("Jump", false);
I changed it to this
if (currentBaseState.tagHash == jumpState)
{
if(!anim.IsInTransition(0))
{
anim.SetBool("Jump", false);
}
}
It now works 100% of the time but will sometimes play the run animation in the air for a few fractions of a second.
Is there a way to transition from one animation to another from any point in the animation?
i.e. if I jump at 0.1 sec into the run animation or at 0.25 sec into the animation I will get the same results.
$$anonymous$$ark the answer as correct :)
I suggest splitting up the animation into seperate clips, so that you can transition back from each. This avoids having very weird transitions
Your answer
Follow this Question
Related Questions
Animation will not Return to Proper State 2 Answers
Mecanim animation transition 0 Answers
Adding animation transition between idle and walk 1 Answer
Why, when I delete transitions from the Animator State Machine, do I get a null reference exception? 3 Answers
Mecanim - How to use "Exit Time" for a state that uses negative speed (anim playing backwards)? 2 Answers