# How do I enable spawners that are in an array?

**URL:** <https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072>\
**Category:** Verse\
**Tags:** unreal-engine, fortnite\
**Created:** [April 15, 2024, 4:43pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072 "2024-04-15T16:43:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![User-c100a1830c](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/user-c100a1830c/32/923183_2.png) [@User-c100a1830c](https://forums.unrealengine.com/u/User-c100a1830c)\
**Post date:** [April 15, 2024, 4:43pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/1 "2024-04-15T16:43:44Z")

</div>

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.

```auto
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")

```

---

<div class="post-metadata">

**Author:** ![bananna\_manuk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bananna\_manuk](https://forums.unrealengine.com/u/bananna_manuk)\
**Post date:** [April 15, 2024, 7:14pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/2 "2024-04-15T19:14:26Z")

</div>

try this

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

```

---

<div class="post-metadata">

**Author:** ![JoggingJohn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoggingJohn](https://forums.unrealengine.com/u/JoggingJohn)\
**Post date:** [April 16, 2024, 7:16am UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/3 "2024-04-16T07:16:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![User-c100a1830c](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/user-c100a1830c/32/923183_2.png) [@User-c100a1830c](https://forums.unrealengine.com/u/User-c100a1830c)\
**Post date:** [April 16, 2024, 8:41am UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/4 "2024-04-16T08:41:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![User-c100a1830c](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/user-c100a1830c/32/923183_2.png) [@User-c100a1830c](https://forums.unrealengine.com/u/User-c100a1830c)\
**Post date:** [April 16, 2024, 8:46am UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/5 "2024-04-16T08:46:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bananna\_manuk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bananna\_manuk](https://forums.unrealengine.com/u/bananna_manuk)\
**Post date:** [April 17, 2024, 7:02pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/6 "2024-04-17T19:02:36Z")

</div>

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

```auto

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

---

<div class="post-metadata">

**Author:** ![User-c100a1830c](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/user-c100a1830c/32/923183_2.png) [@User-c100a1830c](https://forums.unrealengine.com/u/User-c100a1830c)\
**Post date:** [April 22, 2024, 2:20pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/8 "2024-04-22T14:20:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bananna\_manuk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bananna\_manuk](https://forums.unrealengine.com/u/bananna_manuk)\
**Post date:** [April 24, 2024, 4:51pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/9 "2024-04-24T16:51:56Z")

</div>

Just make 5 arrays

```auto
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

---

<div class="post-metadata">

**Author:** ![User-c100a1830c](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/user-c100a1830c/32/923183_2.png) [@User-c100a1830c](https://forums.unrealengine.com/u/User-c100a1830c)\
**Post date:** [May 4, 2024, 10:41am UTC](https://forums.unrealengine.com/t/how-do-i-enable-spawners-that-are-in-an-array/1805072/10 "2024-05-04T10:41:08Z")

</div>

Thanks, I have already solved the problem.
