How to apply the same effects into a range values of an Object Arra

Hello everyone,

I have a project where I have an enemy spawner on top of the level, it is spawning duplicates of the same enemy across the map.

I have made a rotating SAW which I want to make all my enemies die when they touch it, it is working, however only one of the enemies dies when it touches the SAW (index 0 I believe).

I would like to know how can I make this set up to work with the multiple instances of the same enemies that are being spawned into the map.

Is there a note that can look between index 0-50 and do the same for all the values?

Looks like you want a for each for those touching your saw.

Or maybe you have one … hard to tell.

ThompsonN13 Always explains it better then me.


I did not mean Recklessly use a for each. If I where to do this I would do it the way you posted anyway eliminating checks and a need for a for each loop.

My damage systems are way more complex then most so its tough to look at a small snip-it of a blueprint and say I know exactly what he / she is doing everywhere else lol.

Ill give you that it was bad advice on my part but and I forget sometimes my experiences.

I was confused by that question as I did not see an on overlap or on hit and for all I knew he / she built an array of all enemies that made contact with the deadly end of the chainsaw prior and was just pulling from that array and then noticing only calling index 0 of the array my brain went " AHA he / she needs a for each loop " Hence My Response.


Anyway Love ya ThompsonN13 thanks for taking the time to explain it to him.

You Should Make How Too’s lol.

I think Mathew Wadstein got tired of it to and just went berserk and made a how to and what is series with thousands of videos. then when he was done with UE4 Decided to go after Unity as well. I link a lot of his videos on my answers.

in the picture you posted you are only affecting the health of the character at array index 0. an honestly the way you are going about making that script is really bad.

ok so to solve all these issues im going to explain everything i can think of. your going to need three actors for all of this, the enemy character, a spawner, and the saw bp. i am also going to assume that you want each enemy to die when it hits the saw.

ok so first you need to create the spawner. make a new actor and go to the event graph. off begin play search for set timer by event. once you have the timer node set the time to how often you want the enemies to spawn and set looping to true. now drag off the event pin and search for custom event. name the custom event spawn enemy. drag off spawn enemy and search for spawn actor from class. set the class to the enemy you want to spawn. and last you need to set the transform. the transform is where you can get fancy but for the sake of simplicity i just used the actor location.

next make a new character for the enemy class if you havent already.

The last step is to make the saw blueprint. make a new actor and name it (mines named saw). add a static mesh to the components via the add component button. now select this mesh and and drag it to the scene root position to make it the root. with the mesh still selected go to the details panel and first select the mesh to use then scroll down to the collision section. look for the collision preset and set that to overlap all dynamic. now go to the bottom of the details panel and look for the events section and the event on component begin overlap and press the green button. this will open the event graph and make a on overlap node. now drag off the blue other actor node and search for destroy actor. make sure both the blue and white pins are connected and your done.

the result of all this will be that whenever a character or pawn overlaps the saw mesh it will instantly be destroyed. but only that one character will be destroyed.

other answers will say to use a for each node but that would destroy all actors in the array at once.

also you can modify the scripts i provided to spawn at different locations or only destroy actors of a certain type. and i would suggest adding a rotating movement component to spin the sawblade. you can also handle the destruction in the character if you wanted to, but you would need to take the other actor pin and cast to the class of the enemy to get the health values.

haha nah i just sometimes go overboard and make it into a how to.

my first thought was a for each as well but then i noticed all the get all actors and was just like no we gonna try to fix this right instead of adding bandaids. i know what you mean when you say its hard to work off just a small part of a blueprint, thats how most pictures are though and thats the challenge.

ive thought about it. i mean it seems like i explain the same things over and over so making a video one certain things may be a good idea.

Thank you ThompsonN13 for a clear explanation of what is happening on my Blueprint.
I have been following a tutorial but I have been trying to ‘freestyle’ some codes on my own to learn, as you can see I am not a programmer but I really want to learn how to code games in the Engine, really appreciate your time and effort to explain my problem.

and Thank you Exonfluxx for the link, I will be sure to watch those videos as soon as I can