How to Disable/Enable array of Player_Spawner_devices

Hi All!

I’m trying to create my first game and am in need of some help with my player spawn devices.

I have 2 teams, Blue & Red, but they will take turns each round being attackers and defenders, so my setup is currently:

10x spawn pads - Blue Attackers
10x sp - Blue Defenders
10x sp - Red Attackers
10x sp - Red Defenders

each round, I want only Blue attackers and Red defenders enabled. Then switch to Red Attackers / Blue defenders the next round and so on…

I have set up editables:
@editable BlueAttackSpawns : player_spawner_device = array{}
@editable RedAttackSpawns : player_spawner_device = array{}
@editable BlueDefendSpawns : player_spawner_device = array{}
@editable RedDefendSpawns : player_spawner_device = array{}

Set spawn pad functions:

SetSpawnPads():void =
if (IsBlueTeamAttackers = true):
EnableSpawns(BlueAttackSpawns)
DisableSpawns(BlueDefendSpawns)
EnableSpawns(RedDefendSpawns)
DisableSpawns(RedAttackSpawns)
else:
EnableSpawns(RedAttackSpawns)
DisableSpawns(RedDefendSpawns)
EnableSpawns(BlueDefendSpawns)
DisableSpawns(BlueAttackSpawns)

EnableSpawns(Spawns : []player_spawner_device):void =
   block:


# Disable a group of spawn pads
DisableSpawns(Spawns : []player_spawner_device):void =
    block:

If I could have help with the EnableSpawns & DisableSpawns that would be much appreciated!

You would want to use a FOR loop to go through everything in your arrays
With the Object from the for loop, you then want to call its Enable/Disable functions where appropriate

for(Object : Spawns):
   Object.Disable()
1 Like