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

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.

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

Let’s say this is your shooter:

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.

1 Like

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:

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

You’re after this, right:

Image from Gyazo

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

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

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

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.

Thank you so much!