Download

How Do I Get All of My Turrets to Fire at Once?

Hello. I currently have a system setup so that when I press Left Mouse Button, an autoturret will fire a round. However, if I have multiple autoturrets, only one will shoot. The other turrets will not shoot at all. Here is the code I have for the process.


What should I add to the code in order to make all of the turrets fire? Thanks in advance.

First of all you don’t want to use get all actors of class every time you fire.

You need to have an event that creates and updates an array of auto turrets. As each turret is spawned add a reference to the array…TurretArray(turret object reference)

On Fire → get Turret Array → Branch (length > 0) → Foreach Loop → Shoot Tracers from Turret.


Your issue in code is you are only “Getting” the first index (0) of the array result. Thus only one turret fires.

1 Like

Yeah I forgot to edit this earlier. I put the for each loop instead of the get a copy and it worked as I planned.

Definitely set up some events to handle adding and removing from the autoturret array. Get all actors is brutal on performance.