# 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:** 4

<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:** [January 2, 2022, 5:07pm 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/61 "2022-01-02T17:07:03Z")

</div>

And how do you that? Sorry I don’t know.

---

<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:** [January 2, 2022, 11:10pm 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/62 "2022-01-02T23:10:09Z")

</div>

> [@DeadFalconking](#):
>
> A Spawn What? variable is this.  
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/3/832861eecde2e501674e3d017fb44651ac46222c.png)
> 
> What is it that I am doing wrong?

The expose on spawn option is right there.

After you click it, you go to the level, select the spawner blueprint, and in the options to the right you find and set the variable.  
It will have an eyedropper next to it which you can conveniently use to select the item right from the level blueprint.

---

<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:** [January 3, 2022, 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/63 "2022-01-03T05:22:32Z")

</div>

Okay now this is what I’ve done.

> Spawn Enemy Event:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/e/2e3b36ba3ffae5f0c5035007b48f1b57e5231316.png)

> Tick Event:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/5/e56957ec4f4a92c8ae831ae2257526625587d610.png)

> BeginPlay Event:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/c/8cb55ee80e6c3b97aeeca8d48b9824aa818abde7.png)

> BP\_Spawner in Gameplay Level:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/1/31a25ac9643fb0c0bfe775033eec652efbdf4d9f.png)

> BP\_Spawner2 in Gameplay Level:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/5/e/5e46fa05bdaaab94122b5e04659a01eb5a806eca.png)

> V\_Spawn\_Loc:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/1/a/1abfe0fca9e7a9d5b89dcf7012730049315b79aa.png)

> F Spawn Counter:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/d/0/d0bbcb7934d3f1ecc4d50f855e12e344f6ac3bf8.png)

> F Spawn Interval:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/d/9/d9470c94fe5cde70b2d57182d7771e615fdbf362.png)

**Enemy is not spawning now : (**

---

<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:** [January 3, 2022, 7:23am 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/64 "2022-01-03T07:23:08Z")

</div>

> [@post:50](#):
>
> Make sure you don’t spawn on tick.

Why shouldn’t I?

---

<div class="post-metadata">

**Author:** ![AJ\_Graphix](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aj_graphix/32/1194669_2.png) [@AJ\_Graphix](https://forums.unrealengine.com/u/AJ_Graphix)\
**Post date:** [January 3, 2022, 6:07pm 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/65 "2022-01-03T18:07:13Z")

</div>

If you haven’t already, I highly recommend you follow the excellent tutorial series created by Wes Bunn and posted by MostHost\_LA above. Then, do this Twin Stick Shooter course next. It covers a lot of detailed topics and will probably make things easier for you. First log in to your Epic Games account and then click on this link: [Epic Games](https://learn.unrealengine.com/course/2814930)

However, I recommend the following:

Instead of using C++ to complete the “Base Character Class” video, just do it using only Blueprint. For some people, that might be necessary if you don’t want to install bloated Visual Studio software just for some simple items. NOTE: if you do NOT plan to install Visual Studio, do not follow the early steps in this video where Zak creates the C++ class, otherwise you will render all your work up to this point un-openable! So to help you do this video using only Blueprint, I have re-written David’s instructions (from YouTube) the best I can and included his original 2 images from the YouTube comments section in this link: [Twin Stick Shooter BP Version - Google Drive](https://drive.google.com/drive/folders/1TVQeQy1PgY-SvkDH6LsGUEIwFlm_oE98?usp=sharing)

---

<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:** [January 4, 2022, 4: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/66 "2022-01-04T04:31:36Z")

</div>

Ok guys can you help me what should be the Object Wildcard for the BP\_Spawner in my BP\_Enemy (Using Cast To BP\_Spawner)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/3/0387d0800331ea8f552b1f07044a7d1d501b5947.png)

---

<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:** [January 4, 2022, 4: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/67 "2022-01-04T04:59:53Z")

</div>

Probably a “get object of class” or something similar.  
Maybe add a gameplay tag to the spawner and use that like the spawner code did for the spawn spots…

---

<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:** [January 4, 2022, 5:01am 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/68 "2022-01-04T05:01:23Z")

</div>

So I’ll try get object of class. One min

---

<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:** [January 4, 2022, 5:04am 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/69 "2022-01-04T05:04:09Z")

</div>

I tried it, it didn’t work.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/b/9b373edd922798105f3b60d948ccffe06587cc8e.png)  
and there is no Get Object of Class option in Object wildcard

---

<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:** [January 4, 2022, 5:11am 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/70 "2022-01-04T05:11:04Z")

</div>

You really have to learn how to Google.

> **[Finding Actors](https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/HowTo/FindingActors/)**
>
> A How To Guide for Finding Actors in your Scenes in Unreal Engine 4.

---

<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:** [January 4, 2022, 5:16am 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/71 "2022-01-04T05:16:21Z")

</div>

I have a gameplay tag for BP\_Spawner and BP\_Spawner2 in world as Spawn.

---

<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:** [January 4, 2022, 5:41am 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/73 "2022-01-04T05:41:09Z")

</div>

What I just want to do is that call the Spawn Enemy event from the BP\_Spawner in BP\_Enemy. Cause when I spawn the enemy in the BP\_Spawner, it doesn’t spawn where I want it to (outside the map)

---

<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:** [January 4, 2022, 5:52am 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/74 "2022-01-04T05:52:47Z")

</div>

References:

> This is where the Aa Spawn Spots is filled.  
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/4/4/44087e8cb4e9a2cf81306becac86f7b3cc8389d8.png)

> This is the condition so that Spawn Enemy gets activated.
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/d/9dd1e18d6d4197890e05104a525a78385891a2a1.png)

> This is the Spawn Enemy event.
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/2/027f614ba04501cd0cb558fd0a9ff82ccaa0ed24.png)

> BP\_Spawner and BP\_Spawner2 in the level has a tag called Spawn.

This should work according to me, but I don’t know what problem happens. The Enemies still spawn outside the map and not the Location I’ve instructed them to.

---

<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:** [January 5, 2022, 2:33pm 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/75 "2022-01-05T14:33:16Z")

</div>

Okay so I figured out what is the problem but do not know how to solve it.

> So basically there is nothing wrong with the Spawn Enemy event. But the problem is that when in the Tick event it tries to Cast To BP\_Enemy and check whether the health is 0 the **Cast Fails** so the Spawn Enemy event doesn’t get activated. I saw a lot of tutorials on YouTube also saw the UE4 documentation, all of them tell that I should be using Get Player Character as the Object Wildcard for Cast To BP\_Enemy. But it doesn’t seem to work.
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/a/9ac33533c8d35eea11ce0a562704aa95b4e189b0.png)

---

<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:** [January 6, 2022, 4:02am 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/76 "2022-01-06T04:02:40Z")

</div>

@Limanima @AJ_Graphix @SunbeamOut Hey can you guys tell me why the Cast To BP\_Enemy is always failing? ^^^

---

<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:** [January 6, 2022, 7: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/77 "2022-01-06T07:59:39Z")

</div>

That’s because the enemy is not the player character.

---

<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:** [January 6, 2022, 12:59pm 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/78 "2022-01-06T12:59:29Z")

</div>

So what should it be replaced by in the Object Wildcard?

---

<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:** [January 6, 2022, 1:35pm 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/79 "2022-01-06T13:35:29Z")

</div>

I’m sorry to say this, but there are things that you must figure out by yourself, you cannot wait for people around here do the development for you. We sure like to help, but help is not the same as doing everything.

---

<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:** [January 6, 2022, 3:01pm 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/80 "2022-01-06T15:01:42Z")

</div>

There’s nothing on YouTube and in the Documentation of Spawning Enemies. I have seen a lot of tutorials on YouTube and in the Documentation - they are all related to spawning the Player or restarting the game. Please tell me how the Object Wildcard works. Couldn’t find anything helpful in the Documentation.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/a/3a709802a66b19869a0ec5f08252480dc37db0de.png)

---

<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:** [January 7, 2022, 12:43am 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/81 "2022-01-07T00:43:45Z")

</div>

Look up the definition of wildcard.  
Then extrapolate an answer.

[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=3)

[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=5)
