How do I enable spawners that are in an array?

Hey, I have build a map where I planted 5 different Scenarios. Each Scenario has its own 16 spawners and between 4 and 6 different zones. To make the game work I have to implement code that randomly chooses one scenario at the start of the game and activates ONLY the playerspawners and storm controllers that are used for that scenario. I set all the spawners to “Enabled During Phase: None” to disable them all by default. I stored all the spawners and controllers in arrays (array in an array) but now I can’t get the spawners to turn on. I have no Idea how to continue and have insanely little knowledge in verse.

I would really appreciate your help. Im brand new to coding and verse is the first and only language I’ve ever done.

This is my current code that I’ve stitched together by watching hours of Youtube and scrolling to several forums. The comments after the If functions are where the enable option should be.

using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/FortPlayerUtilities }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }


spawn_pad_group := class<concrete>:
    @editable
    SpawnPads : []player_spawner_device = array{}
spawn_pad_group_demo := class(creative_device):
    @editable
    SpawnPadGroups : []spawn_pad_group = array{}
    
    
    OnBegin<override>()<suspends>:void=
        ScenarioChoser : int = GetRandomInt(0,4)
        if (ScenarioChoser = 0)
            #SpawnPadGroups.Enable[0]
        if (ScenarioChoser = 1)
            #SpawnPadGroups.Enable[0]
        if (ScenarioChoser = 2)
            #SpawnPadGroups.Enable[0]
        if (ScenarioChoser = 3)
            #SpawnPadGroups.Enable[0]
        if (ScenarioChoser = 4)
            #SpawnPadGroups.Enable[0]
        Print("Scenario {ScenarioChoser} chosen")

try this

    OnBegin<override>()<suspends>:void=
        ScenarioChoser : int = GetRandomInt(0,4)
        if(Selection := SpawnPadGroup[ScenarioChooser]):
             Selection.Enable()
2 Likes

Just a word of warning that can potentially save you quite some time: enabling/disabling spawners might not be very robust, and can give som inconsistent behavior. Try it out and see if it works, but otherwise, consider using a solution that teleports players to the chosen scenario (you can use any prop as “spawn point” this way, and you can set it to hidden in UEFN), and listens for spawn events, then teleport players to the current scenario.

1 Like

Thank you for your Tip. I will try to implement and try that out!

Hey I tried this but “Enable()” appears in squigglies and it returns the error “Unknown member Enable in spawn_pad_group.”

sorry didnt notice spawn_pad_group is a class with just the SpawnPads array

just move @editable SpawnPads into spawn_pad_group_demo class then

like joggingjohn surgests you can just enable/disable the spawners

you need to set all the spawner in the array to disabled then enable the 1 you want


spawn_pad_group_demo := class(creative_device):

    @editable
    SpawnPads : []player_spawner_device = array{}
    

    OnBegin<override>()<suspends>:void=
       
        # Iterate through SpawnPads array and Disable SpawnPads
        for(i : int = 0..SpawnPads.Length):
              SpawnPads[i].Disable()

        ScenarioChoser : int = GetRandomInt(0,4)

        # Cast the chosen spawnPad to Selection variable

        if(Selection := SpawnPads[ScenarioChooser]):
             # call the Enable function from "player_spawner_device"
             Selection.Enable()

if you are wanting a group of spawn pads to enable / disable you could create an array of spawn pads for each scenario then use ScenarioChooser to pick which array you iterate through to enable a bunch of pads

1 Like

What you said in your last sentence is exactly what im trying to do but everytime I create an array inside an array I cant “Enable” or “Disable” the array cause “Unknown member Enable in `spawn_pad_group” Everytime I try to reference a spawner group I can’t. I can only enable/disable them one by one.

Just make 5 arrays

spawn_pad_group_demo := class(creative_device):

    @editable
    ScenarioOnePads : []player_spawner_device = array{}
    @editable
    ScenarioTwoPads : []player_spawner_device = array{}
    @editable
    ScenarioThreePads : []player_spawner_device = array{}
    @editable
    ScenarioFourPads : []player_spawner_device = array{}
    @editable
    ScenarioDefaultPads : []player_spawner_device = array{}

    OnBegin<override>()<suspends>:void=
       
        # Iterate through SpawnPads array and Disable SpawnPads
        for(i : int = 0..ScenarioOnePads.Length):
              SpawnPads[i].Disable()
        for(i : int = 0..ScenarioTwoPads.Length):
              SpawnPads[i].Disable()
        for(i : int = 0..ScenarioThreePads.Length):
              SpawnPads[i].Disable()
        for(i : int = 0..ScenarioFourPads.Length):
              SpawnPads[i].Disable()
        for(i : int = 0..ScenarioDefualtPads.Length):
              SpawnPads[i].Disable()
        ChooseScenario()

    ChooseScenario():void=

        ScenarioChoser : int = GetRandomInt(0,4)
        
        case (ScenarioChoser):
            1 =>
                for(i : int = 0..ScenarioOnePads.Length):
                     SpawnPads[i].Enable()
            2 =>
                for(i : int = 0..ScenarioTwoPads.Length):
                     SpawnPads[i].Enable()
            3 =>
                for(i : int = 0..ScenarioThreePads.Length):
                     SpawnPads[i].Enable()
            4 =>
                for(i : int = 0..ScenarioFourPads.Length):
                     SpawnPads[i].Enable()
            _ =>
                   for(i : int = 0..ScenarioDefaultPads.Length):
                     SpawnPads[i].Enable()

I’m sure there is a more elegant way of doing this but it should work

1 Like

Thanks, I have already solved the problem.