How to stop previous animation?

So I’m kinda new to animation in unity and the problem I’m having is whenever i have my character jump it first has to finish the walking animation then it starts playing the jumping animation.

What I want it to do is as soon as the player presses the jump button, the character stops its animation immediately and starts playing the jump animation.

Thanks in advance.

If your using the animator you might have to set ‘Has Exit Time’ to false on the transition between your two animations. You can find it in the inspector when you click on the transition between animations in the animator window, it looks like this:

Otherwise if your using the animation component, as you said you could stop the walk animation and then play the jump one afterwards, to do this use Animation.Stop("your walk animation name"); and then play you jump animation.

Hope this helps.