Array of Barriers shows as size zero?

This is my code:

OnBegin<override>()<suspends>:void=
    PrintBarrierLength()

RemoveNextBarrier(AreaID : int) : void =
    Print("Barrier removal starting. Stage: {AreaID} Barriers Length: {Barriers.Length}")
    if (var CurrentBarrier : barrier_device = Barriers[AreaID]):
        Print("Barrier found, removing.")
        CurrentBarrier.Disable()

PrintBarrierLength() : void =
    Print("Barriers Length: {Barriers.Length}")

I’m setting it up with a single barrier device in the array. My first print shows the Barriers.Length as 0. What am I doing wrong?

Note: I have added quite a bit of logging in to attempt debugging this. It looks like the length of the array changes as I enter the RemoveNextBarrier function; I am tracking this through prints, and I’m pretty sure something in here is a bug. Is it possible that disabling the barrier is predicted and happens before I actually do it? The barrier stays in place, but the array is showing as empty and nothing actually happens.

LogVerse: : Dodging with prop 5
LogVerse: : Barriers Length: 1
LogVerse: : All Targets Destroyed
LogVerse: : Moving to next stage. Current stage : 0
LogVerse: : Barrier removal starting. Stage: 0 Barriers Length: 0

I can’t see anything wrong based on that snippet, can you post the full file?

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

See Create Your Own Device Using Verse for how to create a verse device.

A Verse-authored creative device that can be placed in a level

barrier_manager_device := class(creative_device):

@editable Barriers : []barrier_device = array{}
@editable FirstBarrier : barrier_device = barrier_device{}


OnBegin<override>()<suspends>:void=
    PrintBarrierLength()

RemoveNextBarrier(AreaID : int) : void =
    Print("Barrier removal starting. Stage: {AreaID} Barriers Length: {Barriers.Length}")
    if (var CurrentBarrier : barrier_device = Barriers[AreaID]):
        Print("Barrier found, removing.")
        CurrentBarrier.Disable()

PrintBarrierLength() : void =
    Print("Barriers Length: {Barriers.Length}")

After taking the code into an empty island and setting things up, it looks like it’s something weird in the files of the island it’s on. I’ll just need to rebuild things.

After looking through the project for the twentieth time it turns out I wasn’t filling in an editable variable I had added on one of the objects. If editables were able to be set to required and error-causing, or if I weren’t occasionally a complete buffoon, this problem could be avoided.

This happened way too many times to me as well, error on empty would be nice

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.