[Verse] Normal - Variables do not reset on new rounds

As the title suggests, variables do not appear to revert to default values when a new round is launched.

This could be because I’m manually clicking “end game” and the end game state is not being triggered through game settings or a device, as I don’t see my log for the OnEnd function when doing so.

Thinking about this, it would be beneficial in some circumstances to keep variables persistent for the entire game, but the default functionality should reset everything upon a new round.

I may be missing something here, so please correct me if I’m wrong.

Hi @AxelCapek:

Thanks for the bug report. I tried to reproduce your issue with a simple script, but wasn’t quite able to:


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

device_script_log := class(log_channel){}

# Your new device script
my_device := class<concrete>(creative_device):

    DeviceScriptLog:log = log{Channel := device_script_log}

    @editable
    var myprop:int = 5

    OnBegin<override>()<suspends>:void=
        loop:
            Sleep(2.0)
            set myprop += 100
            DeviceScriptLog.Print("{myprop}")

When I end the game via hitting [Esc] and selecting [End Game], then clicking play again, I see the first value being printed out as 105 as expected. Are you ending the game a different way?

If you are able to reproduce this in an isolated example, could you please share your full Verse script?

Thanks @sonictke

Interesting, you use @editable before creating a var. Is this standard practice? If so, why?

Also this happens in all my projects. I do not necessarily set my variables during OnBegin, could this be the difference?

Interesting, you use @editable before creating a var. Is this standard practice? If so, why?

@editable is a specific attribute for UEFN that allows for a Verse-authored device to expose variables to the editor to allow for control within the UI. Please see:

https://www.epicgames.com/fortnite/en-US/creative/docs/uefn/Verse/expose-verse-properties-to-unreal-editor-for-fortnite

Also this happens in all my projects. I do not necessarily set my variables during OnBegin, could this be the difference?

Could you share a full sample of one of your project’s Verse scripts? It depends on where you’re defining the variable in question.

1 Like

I am also having this issue, I could provide my verse script if you’d like?