Playing dodge animation on button press

Hello everyone,
I was thinking of making a dodge system where the player could dodge an attack. Now I have 4 animations with me, dodging in all four directions, but how would I make it work. I have made animations using blend spaces, but I guess its not a blend space solvable problem. And on playing the animation I would also like the character to move in the said direction. I think I will use shift plus the wasd keys for the dodge movement.

I guess to start with I’ll say, just think of dodging just as running or walking, but as a one time thing, not looped. You can therefor set it up as your running or walking but when you call it, you just have it play once and then blend back out.

Personally I have my dodge set up as a montage that I call and it’s only one animation, not done with blend spaces because my character always face forward, never strafe, etc. You could take that approach but if your character can strafe and run backwards, you may want to use blend space so you can get those in between types of situations… the 45 degree, or whatever.

I use root motion to move the character when dodging. It was just the easiest solution. But you can manually move the capsule as well. For my attacks I do just that, I basically over ride input with a timeline ramping up speed. This can be done probably in various ways, it’s easy enough to deal with, however you choose to do it.

With my dodge the way it works is it basically goes in the direction you’re currently facing. It’s a one step operation. Press button results in a dodge… going forward. You can certainly set it up so it’s a 2 step operation where you first press the dodge button, and then press the direction. It’s a matter of branching movement behavior. Simply pressing a direction results in normal movement (dodge = false), but holding “shift” or whatever for dodge, results in dodging (dodge = true). Pressing shift while running, should then also produce dodge.

Conceptually it’s not too complicated. Just take it through the steps implementing. I’d say get your input set up and get the dodge to “kick in” as desired, then worry about animations and stuff. You’ll quickly see how you need to go about then implementing animations to get the right feel for the move. If you actually need blend spaces or not… etc.

Hey Obihb,
I would like to thanks for the response! Really.

I also thought using a blend space could be a good way to get it working. I am creating a 1D blend space which takes in the direction as a parameter for the rotation. So I guess taking the rotation from X vector would be good to get the rotation for the direction?

And then I would have to link it into the pre existing run animations? So I can use transitioning into that blend space on shift?

Any other suggestions?

And thanks!

So I implemented it, the first one is the default blend!
Then is the default anim graph
And then the condition of changing or going into the dodge state
Then setting the direction
Then is the setting of direction
And then is the setting of dodge

So the problem I am having is that the animation plays, but keeps on playing till I keep on pressing shift, regardless of me not leaving it also.
It works properly inside of the personas preview window when I change the direction, but it keeps on playing whenever the shift is kept pressed

I would be thankful if you could help me any further!
And thanks for whatever you did till now too! :slight_smile:

I guess it depends on what’s your blend back condition.

I’m not sure I get exactly what’s happening, I always find it harder to tell when just looking at shots. But here’s the theory.

To start the dodge you need two conditions, holding shift and pressing a direction. I think it could be both done with boolean. So, sure you use direction to tell the blend space which direction but you still need a start condition and since you want to control it by holding shift, you probably need two things set. Shift tells what it’s gonna branch to and direction actually start the dodge. You could do this purely in the character blueprint and set a final “DoDodge” or whatever boolean for the animation blueprint.

So you press shift “CanDodge = True” now you press a direction while shift is down, now “DoDodge = True”. Under any other conditions that DoDodge would be false. So as soon as it’s true this starts the dodge to blend in.

Then for the blend back it should be based on time remaining on the animation and not based on what is pressed or what booleans are set.

In your character blueprint meanwhile, you’ve set “DoDodge” to true right?. Now as soon as that is true, dodge animation kicks in and you can set it back to false. So you can literally have a 0.1 delay to set DoDodge back to false. You can also set it back to false by releasing shift. Now you will need to have some form of spam check in place so you can’t just spam the input to try produce a dodge. So while CanDodge is true, you can set DoDOdge true by pressing a direction, but while CanDodge is false, you can’t.

But anyway, this is my theory about it… in… short?.. :slight_smile: Not sure if I’m missing anything imortant. It’s easy to spit out theory but can easily miss something to make it work in practice. And of course there are multiple ways to go about doing this. But I hope this makes sense. I use this technique of blending animation on my boss character. I basically set booleans true to start and back to false immediatle, allowing animation to control it’s own blend back and not true or false conditions.

Hey thanks for all the help, really!
And it is working, really thanks!

All credits to you.

Awesome, glad you got it working.