How can I play the same animation twice (re-enter the same state when it's finished)?

Hello,

I need to play a same slash animation twice, or more times, in my state machine (slash, slash, slash… if player spams the button). The slash is one-off animation (not made to loop).

What I want is, when a slash animation finishes, if player don’t press the button again, it transits back to idle. If player press the button again, it re-enters to the slash node itself again.

I use a conduit to do it, as the following picture. The transition rule from attack to conduit is remaining time rate < 0.1. The transition rule from conduit to attack can always be true if player spams the button. It seems it won’t restart the slash animation when it re-enters. I end up stuck at the last frame of the attack forever.

234848-2018-03-23-20-15-55-psmcharacteranimationblueprint.png

I know that if I transit to an idle node first then go back to attack, it work. But a brief idle pose in between breaks the fighting rhythm of my game. I need a slash right after another.

There is an “always restart on entry” option. But it won’t work, because technically I’ve never left the attack state.

How could I solve this problem?

Thanks.

I think you could use an anim montage to accomplish this. If you have a start → loop → out set of anims for this attack: Have your looping portion of the attack be a section within the montage and set it to loop indefinitely, with a notify so you can count how many loops play out, then when you have the number you want, set the next section to your out animation.

Then in your anim bp you would take the pose from whatever slot your montage is playing on and place that as the output pose.

See Animation Montage Editor in Unreal Engine | Unreal Engine 5.2 Documentation

The way to get a section to loop in the montage is really goofy and unintuitive, but it’s possible and accomplishes what you’re looking for I think.

Anim montage is usually the best solution, but you could use a Boolean as the transition rule (IsHoldingBtn for example) now the important part is to select the animation inside the state/conduct and set it to loop. Just like in the ThirdPersonBP they have the jump loop constantly playing as long as the player is falling, you can do something like that.