# How do i destroy everything spawned by an object when i destroy the spawner?

**URL:** <https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987>\
**Category:** World Creation\
**Tags:** gun, Destroy-Actor, unreal-engine, Physics, projectile, question\
**Created:** [March 9, 2021, 4:34pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987 "2021-03-09T16:34:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 9, 2021, 4:34pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987/1 "2021-03-09T16:34:08Z")

</div>

Ok so I have a ProjectileEnemy that spawns EnemyProjectiles on a delay. I want to make it so that whenever I destroy the ProjectileEnemy, all the EnemyProjectiles are destroyed as well. I have tried both “Get All Actors of Class” and promoting the spawned projectile to a variable. (that’s what it says to do in the docs, but it only destroys the most recently shot one.) I have it set so that the level only advances when all actors with the tag “enemy” are gone, but I have to have the EnemyProjectiles with that tag for other reasons. And I want the projectiles to go away when the spawner is killed anyway.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 9, 2021, 4:58pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987/2 "2021-03-09T16:58:57Z")

</div>

Let’s say this is your shooter:

 ![331920-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/6/fb6f69609372fbfc3ea627f63b20cdefa8862842.jpeg)

As it spawns projectiles (here, 4 times per second - no need to flood-muddle things with _Delays_), we add them to an array. When this shooter gets `Destroyed`, we loop through the array and also `Destroy` the projectiles inside.

* * *

There’s no need for _get all actors_ / _tags_ shenanigans. At least not for this.

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 9, 2021, 5:08pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987/3 "2021-03-09T17:08:54Z")

</div>

so in place of event destroyed, would i connect that to just before my destroy actor node?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 9, 2021, 5:41pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987/4 "2021-03-09T17:41:14Z")

</div>

No, just destroy the spawner as you already do. When you destroy this actor, it will call its own event, you can override it like so:

 ![331923-screenshot-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/1/d41eaa4e1e6e7e6a514f78d76e1900dd1ce2bea8.jpeg)

Essentially, when this actor is asked to Destroy itself, it will execute its own _Event Destroy_ which can trigger other things inside it.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 9, 2021, 5:47pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987/5 "2021-03-09T17:47:17Z")

</div>

You’re after this, right:

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/2/e62d1da9050b5b86996979a0ba06f8250fb6bd87.gif)](https://gyazo.com/6d5859f4dca8cfdaa9c86a6ef7c8631a)

I destroy the actor that is shooting, and it destroys all its bullets.

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 9, 2021, 9:27pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987/6 "2021-03-09T21:27:51Z")

</div>

Okay thank you, but how did you do “all projectiles spawned by this shooter”? I can’t find anything that puts out an array like that.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 9, 2021, 9:37pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987/7 "2021-03-09T21:37:28Z")

</div>

It’s an [array][1]. It’s a new variable you create yourself, choose a type and set it to be an array:

 ![331928-screenshot-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/8/eb8ce90f81d9c238f4b853a5fb4ee09b06a3ceaa.jpeg)

If you’re not sure what type to choose, you can promote the return value to variable and set that to be an array:

![331929-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/3/29375812d05aad417a6bbb76f20e69970a5370b6.jpeg)

---

<div class="post-metadata">

**Author:** ![GamerAwesome949](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GamerAwesome949](https://forums.unrealengine.com/u/GamerAwesome949)\
**Post date:** [March 9, 2021, 10:06pm UTC](https://forums.unrealengine.com/t/how-do-i-destroy-everything-spawned-by-an-object-when-i-destroy-the-spawner/479987/8 "2021-03-09T22:06:33Z")

</div>

Thank you so much!
