How to send an event from an Animation Blueprint to a Behaviour Tree Task?

Hello,

I’m looking for a way to send an event (when an animation has finished) from the Animation Blueprint back to a Task in the Behaviour Tree so it can carry on etc. Does anyone know how this could be achieved please?

I thought an interface might be a solution but couldn’t figure out what to set the Target to when communicating back to the Task.

In this situation I can’t play the animation in the Task itself, well I could but I would end up having to duplicate a lot of logic into other Tasks, hence using the Animation Blueprint.

Thanks,

Mark.

Well, a simple variant would be something like that:

  • when you want to play your animation in your BehaviourTree Task, set a bool on the blackboard to true (i.e. playMeleeAnimation=true)
  • in your animblueprint you can check for the blackboard variable, if its true -> transition to the animation
  • Do a animnotify for when the animation ends in your AnimBlueprint and set the blackboard variable to false
  • in your task you can check in your Event Tick if the bool has been set to false and react accordingly (go out of the task or whatever)

At least thats what i do in my BT. Though, there seem to be some issues with timing of when variables on the blackboard are set and checking them in the Tick, i am still in the process of figuring the exact cause…

Cheers,

Thanks for the reply , I’ll give that a try. I wonder if the timing issue you mention is due to the Service tick setting, if that’s quite infrequent it might affect it?

It would be best if an immediate event/notification was possible, especially with animations where a delay will be more noticeable.

Thanks again,

Mark.

When i think about that, maybe it would be better to have a State / bool in your pawn instead of the blackboard. Since one should seperate stuff like BlackBoard/BT from Pawn/Controller/AnimBlueprint, this could be the cleaner variant.

So instead of the BlackBoard variable, you could get the pawn that is controlled by the owner-controller and set the variable there. This way you can give the Pawn i.e. a state “MeleeAttacking” and according to the state of the pawn, the correct animation is played. As soon as the state is reverted to i.e. “Idle” by AnimationEndNotify, the BT Task knows that the animation has finished.

As far as i know, there is no way to call an event on the BT directly from Controller/etc, at least none that would not be very hacky.

Also, i couldnt see a problem with the Tick-Timing that has a negative effect on the animation. Though, i didnt try with Services yet, since these could have custom-tick values like > half a second, which would then of course be noticable.

Cheers,

Yes that’s a much cleaner way of doing it. I guess I was so fixated on it needing to be an event I overlooked the more simple approaches :slight_smile:

Thanks, it’s working fine.

Mark.