Animation Blueprint Frozen in State

Hey all, I’m having an issue with my animation BP at the moment.

The player can transition from Locomotion into Attack, when the “isAttacking?” bool gets set (updated from the Player Character)

This works perfectly apart from the fringe case of the player pressing attack (triggering “isAttacking?” to true) while a previous Attack state is still transitioning back to Locomotion, despite transition rules preventing this (I think). The player will finish the current attack animation, briefly stop at the Locomotion state, then re-enter the Attack state without the animation playing for some reason which gets it stuck as the notifier never fires again.

Transition rule Loco > Attack:
image

Transition rule Attack > Loco:
image

I’ve attempted to remove the issue by reducing the transition time from Attack > Loco to 0, while it’s improved the issue, the bug is still possible.

isAttacking?
Set: Player attack input
Unset: Anim notify triggers at end of attack animation, player is bound to this, and unsets the player variable.

Any help would be fantastic, thanks!

Hey @Donny000!

This is something I’ve run into before while trying to create an animation-focused action game with precise attacking and commital to actions a la Dark Souls- please take my advice here.

Put these bools on your player character (or even better, if you have it- a component) and have them update on the update track of the AnimBP’s Event Graph.

You can even get rid of that state entirely if you switch to using montages for your attacks (which I HIGHLY recommend) because then you can check the “Is Attacking?” bool and stop the player from running the attack code entirely and keep this from happening.

The biggest reason for this though: If an animation is interrupted, NOTIFIES DO NOT FIRE AFTER THAT POINT. Also framerate- if a notify is too early or too late in the animation and there are some frames that had to be skipped, it is likely not to go off at all.

1 Like

100% do not use notifies for anything that requires accuracy or execution.

Lets make a few quick assumption.
You hit attack.
The character can immidiately attack (this is a bit of a big assumption btw, in code you should verify its true before committing).
Sequence plays.
Sequence ends.
Variable needs to be reset or you cannot attack again.

Assumption: known sequence lenght.

Solution.

Attack input > toggle bool > delay by sequence time > reset bool.

This will always happen, even if an attack was interrupted (which in a game is probably what you really want?).

Yes, montages are a way better idea.
And… Coding time stuff like this is almost always a really bad idea…

Ofc, there is one - and only one - exception to notifies.
They can be called from ABP state transitions.

Notifies called in that manner are always triggered as they arent async and can therefore be somewhat more reliable.

Should anyone rely on that? No, probably not. Mostly because its bad practice, not because it wouldnt work in a pinch…

1 Like

You can even get rid of that state entirely if you switch to using montages for your attacks (which I HIGHLY recommend) because then you can check the “Is Attacking?” bool and stop the player from running the attack code entirely and keep this from happening.

The biggest reason for this though: If an animation is interrupted, NOTIFIES DO NOT FIRE AFTER THAT POINT. Also framerate- if a notify is too early or too late in the animation and there are some frames that had to be skipped, it is likely not to go off at all.

Funnily enough, that’s exacly what this project is! :sweat_smile:

And yes, the bools are being set by the PlayerCharacter, and then kept up to date in the AnimBP update as the Player changes them.

It’s part of a university project so it’s unfortunately a little late for me to swap everything over to montages now, though I definitely need to invest some time into investigating them.

Ah interesting about the notifiers, so would a notify state work better to try to catch any rogue frames, or are they only for montages?

Thanks, yeah I’m gathering that notifies are going to be an issue.

I’m doing plenty of checks pre-attack to ensure the Player should attack - falling, already attacking etc. and my debugging of the variables during runtime all checks out with them being assigned as they should. So, it certainly sounds like notifiers are the culprit.

Unfortunately, I can’t hard code the times because the player and enemies share an AnimBP with variations in play rates from each actor depending on variables like “exhaustion”.

I wasn’t aware that notifiers could be called on transition though, that sounds like it could be a workaround! Any chance you could screenshot an example, as I’m sure I’ve tried this but can’t work out how to incorporate execution pins in a transition.

Thanks!

Regarding Notify States, from the documentation:

The idea here is this section:
image

This GUARANTEES 3 things, a begin event, an end event, and a tick event.

@Mind-Brain
I don’t think the start/end are going to fire at all if the animation is cut short before the notify.

@Donny000
If you click the transition, look in it’s Details.

Start Transition, End Transition, and Interrupt will all actually fire whenever the transition is called.

Again, not best practice, not something I’d use on the regular.