How could I destroy all spawned projectiles by pressing Z?
Hello,
Create an event for z pressed.
Then iterate on GetAllActorOfClass (your class).
Then iterate on your array output.
To finish call destroy function in all iteration.
Although GetAllActorsOfClass (see https://docs.unrealengine.com/en-US/Gameplay/HowTo/FindingActors/Blueprints/index.html) would work, it is very computationally intensive. It would be better to add the projectiles to an array as they are spawned, and then, on pressing the button, looping through that array, destroying the projectiles.
Thank you, sounds even cooler but the player might go through a looong line of destroys because the weapon has infinite ammo. May I ask you to demonstrate the BP? I’m a bit confused here:
Thanks, would you mind showing me the BP so my head can connect this theory? (I’m a total beginner).
Oooohh… I tried deactivate. It works! Thanks!
Question nearby; where would I connect an explosion particle emitter (on destroy)?
On array element select node destroy actor.
Thank you, it works. Is there any way to connect an explosion emitter when they’re destroyed?
I consider both answers as the best. (I’ll have to stick to the most simple one.) Thanks Jezcentral
Yes of course just get in the loop the location of your actor by get location and after call a node spawn emitter at location.
Be sure to call get actor location before destroy this one!!!
A best way to do that is to do that in thhe on destruct function in your actor class.
Can’t picture it. Should I drag out the “Loop Body” pin? And then?
A sound works, but the emitter doesn’t. Why is that?
You are using spawn sound a sound is a sound not a particule emitter =)
Sure! It should make a “■■■■■” and a visible explosion. I’ll design the sound myself.
The emitter doesn’t work, though. can you screenshot the whole Blueprint?
I m sure the emitter work but you currently spawn it at location 0,0,0 if this location is under your terrain or any other place who is out of screen you will not see it.
Use actor location in the loop to spawn the emitter at the exact location of your actor.
In your last picture, what is the second line and location pin connected to?
EDIT: OH I got it. Thanks a lot man.
Hit location from a line trace but in your case extend array element select node
getActorLocation and connect it to location of emitter that should work
Yes you need to extend the array element of the for each to get actor location