How do i make 4 (Objects,Turrets) fire randomly one at a time?

How do i make 4 (Objects,Turrets) fire randomly one at a time?

make a TurretManager actor, which has an array of TurretActor references. place the manager into the level near the turrets, and add the other turrets to its reference list using the eye dropper in the details panel.

you can give the turrets a boolean called AutoFire, which defaults to true, and on begin play, the manager can check if their reference array length is greater than 0. if so, it should go through that array, and set each turret’s AutoFire property to false.

then, the TurretManager can have a timer function that can get a random integer, mod by the length of the reference array, and call fire on the turret at the randomly chosen index.

Would there be a simpler way to do this because the turrets are going looking at the target at all times and the target isn’t going to be moving so basically they are gunna shoot in straight lines.

You could add a RandomStream to your turret, at begin play call Seed Random stream and call a timer function wich gets a random float representing the min/max seconds between shots, the timer then calls your shooting code when it is up, just fire the timer again at the end of the shot so it gets a new random delay until its next shot.

If you want the turrets to fire with static delays but a random turret you should use ScottSpadeas TurretManager Idea, or let the turrets have references to each other and the last shooting turret randomly calls one of the other turrets to shoot next.

it doesn’t matter if the turrets are aiming at a target or automatically spinning around, or shooting straight forward, because aiming is a separate problem from shooting, and my solution only addresses firing from one randomly chosen turret at a time. you could replace the turret with a blinking light or floor spikes, and the solution i gave would work the same.

whether you want 3 lights to randomly blink one at a time, or you want each turret to shoot one at a time, they will need to share some information with each other or with a manager actor, so that they take turns properly.

Thanks… so basically i just have to make a Turret Blueprint with one Turret and then i can just place that Blueprint into the level as many times and they all will fire randomly as long as i set the Min and Max high enough. Or will they still fire at the same time since i’m just placing copies of the Original?