Hi, I’m really new to Unreal and can not find any information or tutorials on killing the AI when their health bar gets below zero. I wanted to add an animation montage instead of ragdoll. I have set up an animation montage with the death animation. I have attached the two set ups I’ve tried and they seemed to have worked for others, and like I said I am new so I’m wondering if there something I need to put in the level blueprint maybe? I am a student and just learning unreal engine so this might be a really simple concept, but I just can not find much help. I would like to use the death animation when the AI health bar hits zero, then eliminate the AI. Any help or tips on where to find better information on health bar dying tutorials is greatly appreciated. Thanks.
You’ll first need two float variables within your AI blueprint to store current health and max health. Let’s just say that you set the default values of both to 100.
Now instead of using the tick, use the ‘Event Any Damage’ node within the AI Blueprint. This is used to register damage from any source to the actor. So you can use it to get the damage and subtract the said amount from your current health. Then check if current health goes below zero. If it does, call your animation montage and destroy the actor after a delay of say 2 seconds for the actor to finish it’s death animation.
Of course, you’d need the player to inflict damage on the AI character. For simple prototyping just use the ‘Apply Damage’ function with a reference to the AI actor as the input.