# How to play Death Animation whenever the enemies Health is 0? (In Blueprints or C++ and spawn again with the AI Controller)

**URL:** <https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910>\
**Category:** Character & Animation\
**Tags:** unreal-engine, Blueprint, UE4-27, question\
**Created:** [December 23, 2021, 5:21am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910 "2021-12-23T05:21:44Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 27, 2021, 5:52pm UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/21 "2021-12-27T17:52:38Z")

</div>

Oh yeah thanks, I’ll try it!

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [December 28, 2021, 12:28am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/22 "2021-12-28T00:28:39Z")

</div>

> [@Limanima](#):
>
> if you are respanwing the enemy after he’s dead, why are you destroying him

Because that’s actually the proper way to do it.  
Destroy gets rid of it and any variable.  
when you re-spwan you usually create a new actor from the class so that all the variables are reset.

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 28, 2021, 6:36am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/23 "2021-12-28T06:36:16Z")

</div>

**The Problem:** Game crashes after 3-4 seconds or so, showing this error.

> Assertion failed: DelegateOwner-\>IsValidLowLevelFast(false) [File:D:\Program Files\Epic Games\UE\_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/SparseDelegate.h] [Line: 196]
> 
> UE4Editor\_Core  
> UE4Editor\_Core  
> UE4Editor\_Monster\_Shooter\_0015!AEnemy::BeginPlay() [D:\Game Development and Programming\Monster\_Shooter\Source\Monster\_Shooter\Enemy.cpp:48]  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Monster\_Shooter\_0015!AEnemy::Tick() [D:\Game Development and Programming\Monster\_Shooter\Source\Monster\_Shooter\Enemy.cpp:58]  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Core  
> UE4Editor\_Core  
> UE4Editor\_Core  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_UnrealEd  
> UE4Editor\_UnrealEd  
> UE4Editor  
> UE4Editor  
> UE4Editor  
> UE4Editor  
> UE4Editor  
> UE4Editor  
> kernel32  
> ntdll

**References:**

> Error code line 48 in Enemy.cpp file.
> 
> DamageCollision-\>OnComponentBeginOverlap.AddDynamic(this, &AEnemy::OnHit);

> Error code line 58 in Enemy.cpp file.
> 
> if (!CurrentVelocity.IsZero())

> BP\_Enemy Blueprint.
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/a/0a8c46f562dc885e3453dddf455f9786e38aa5dc.png)
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/1/6/1601a0cb8df027277e5937efba85b4c0567ab5a0.png)

> Idle / Walk to Dead Transition in BP\_Enemy\_Animation Blueprint.
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/7/3798fa6dbf1bdfeba3b5d915590e9cdb02e4f62f.png)

---

<div class="post-metadata">

**Author:** ![Limanima](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/limanima/32/248560_2.png) [@Limanima](https://forums.unrealengine.com/u/Limanima)\
**Post date:** [December 28, 2021, 9:49am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/24 "2021-12-28T09:49:12Z")

</div>

> Because that’s actually the proper way to do it.  
> Destroy gets rid of it and any variable.  
> when you re-spwan you usually create a new actor from the class so that all the variables are reset.

Yes, you are absolutely right, no problem there.  
But what about setting “owner=self” in Spawn Actor? Wouldn’t that cause problems because “self” was destroyed?

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 28, 2021, 9:50am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/25 "2021-12-28T09:50:01Z")

</div>

Ok so what should I do now?

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [December 28, 2021, 11:45am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/26 "2021-12-28T11:45:36Z")

</div>

Owner on a character can’t really be self.  
It usually the player or AI controller that owns the actor…

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 28, 2021, 11:46am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/27 "2021-12-28T11:46:39Z")

</div>

Okay thanks, I’ll see if that works!

---

<div class="post-metadata">

**Author:** ![Limanima](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/limanima/32/248560_2.png) [@Limanima](https://forums.unrealengine.com/u/Limanima)\
**Post date:** [December 28, 2021, 1:57pm UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/28 "2021-12-28T13:57:13Z")

</div>

Just don’t set the owner.  
No actor owns the enemy.

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 29, 2021, 5:22am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/29 "2021-12-29T05:22:25Z")

</div>

@MostHost_LA @Limanima **Game Crashes:** Even if I set the Owner as GetAIController. Even if I set the GetPlayerPawn. Even if I don’t set any Owner.

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [December 29, 2021, 5:26am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/30 "2021-12-29T05:26:23Z")

</div>

“Game crahses” means nothing.  
at a bare minimum you need to share an error message.  
Probably install the debug symbols and cause the error again - so you can get a meaningful error.

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 29, 2021, 5:27am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/31 "2021-12-29T05:27:44Z")

</div>

Okay here you go.

> Assertion failed: DelegateOwner-\>IsValidLowLevelFast(false) [File:D:\Program Files\Epic Games\UE\_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/SparseDelegate.h] [Line: 196]
> 
> UE4Editor\_Core  
> UE4Editor\_Core  
> UE4Editor\_Monster\_Shooter\_0015!AEnemy::BeginPlay() [D:\Game Development and Programming\Monster\_Shooter\Source\Monster\_Shooter\Enemy.cpp:48]  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_CoreUObject  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Monster\_Shooter\_0015!AEnemy::Tick() [D:\Game Development and Programming\Monster\_Shooter\Source\Monster\_Shooter\Enemy.cpp:58]  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Core  
> UE4Editor\_Core  
> UE4Editor\_Core  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_Engine  
> UE4Editor\_UnrealEd  
> UE4Editor\_UnrealEd  
> UE4Editor  
> UE4Editor  
> UE4Editor  
> UE4Editor  
> UE4Editor  
> UE4Editor  
> kernel32  
> ntdll

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [December 29, 2021, 5:29am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/32 "2021-12-29T05:29:48Z")

</div>

> [@DeadFalconking](#):
>
> DelegateOwner-\>IsValidLowLevelFast(false)

Whatever you are feeding into it is an NON valid variable.

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 29, 2021, 5:31am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/33 "2021-12-29T05:31:19Z")

</div>

So is there any way to fix this, or I have to find it?

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [December 29, 2021, 5:51am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/34 "2021-12-29T05:51:14Z")

</div>

Have you looked at any particular respawn tutorial?  
Or are you just guessing what to do?

We have no idea what you are actually doing code or BP wise, so it’s near impossible to offer suggestions short of general things…  
Like, try to validate the variable before use…

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 29, 2021, 5:59am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/35 "2021-12-29T05:59:23Z")

</div>

I am referring to this UE4 docs tutorial - [Spawning and Destroying an Actor | Unreal Engine Documentation](https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/SpawnAndDestroyActors/)

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [December 29, 2021, 6:54am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/36 "2021-12-29T06:54:14Z")

</div>

Which part in there are you stuck on / where did the owner really come into play?

Also - where is this code?  
Surely you aren’t expecting the actor to Spawn itself into existence?

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 29, 2021, 6:55am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/37 "2021-12-29T06:55:33Z")

</div>

Whenever I hit play after around 5 seconds the Game crashes showing that error message, basically when the Spawn Enemy function comes to play.

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [December 29, 2021, 6:58am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/38 "2021-12-29T06:58:26Z")

</div>

Doesn’t sound like you followed the tutorial.  
I see nothing in there about owners at a glance.

At a base level.

Create an actor that manages spawning of units.

Create an array of classes. Populate the default values with however many entries you want to start to spawn.  
Follow the tutorial to Spawn.  
Use the array and a for loop to Spawn multiple.

Whenever a unit is destroyed, call an interface call to Spawn a new one.

Done.

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 29, 2021, 6:59am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/39 "2021-12-29T06:59:15Z")

</div>

Okay thanks I’ll try that.

---

<div class="post-metadata">

**Author:** ![DeadFalconking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deadfalconking/32/250507_2.png) [@DeadFalconking](https://forums.unrealengine.com/u/DeadFalconking)\
**Post date:** [December 29, 2021, 9:20am UTC](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910/40 "2021-12-29T09:20:53Z")

</div>

Enemy is spawning but in random position all out of the map, I tried GetActorTransform, I tried this too.

> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/b/2b04b53434fd835c1b532c28d84acc3c53b21485.png)

> This is where the BP\_Spawner is almost in the end of the map.
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/d/a/da06a667744309b9b5e1027a305e692d7eb4306e.jpeg)

Also now they are spawning and there is no crashes and stuff happening.

[Previous page](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910.md?page=1)

[Next page](https://forums.unrealengine.com/t/how-to-play-death-animation-whenever-the-enemies-health-is-0-in-blueprints-or-c-and-spawn-again-with-the-ai-controller/267910.md?page=3)
