How to play animation and destroy actor from BTTask?

I set up a simple Behavior Tree, and I’d like to make a task that plays a death animation and destroys the actor.

However, I can’t even destroy the actor. The Destroy Actor node has no effect.

How do I get animation blueprint from BTTask? I want to set a variable there, to signal it to play the death animation. Why doesn’t Destroy Actor have any effect in this task?

One thing you’re missing here, that causes your issues, is that OwnerActor in EventReceiveExecute is a Controller not a Pawn. So when you call destroy you don’t destroy the pawn on the level, you destroy his brain! :smiley:

To get access to AnimInstance of your AI you need a sequence of calls:

  1. cast OwnerActor to a controller
  2. from the controller get the pawn with GetControlledPawn call
  3. cast retrieved pawn to Character class
  4. from resulting character instance get its skeletal mesh with GetMesh call
  5. you can get AnimInstance from the mesh with GetAnimInstance call

Cheers,

–mieszko

Works like a charm, thanks!
I forgot that Controller is also an Actor. The plug OwnerActor tooltip says “object’Actor’ Owner Actor”, my wires short-circuited and I assumed it must always be the character/pawn :slight_smile:

how do you get the event receive execute? i cant even find it!

Because this is custom event, you can create it by typing “add custom event”