Session Variable, works in my editor session, not for my published maps?

My code is almost the exact same as Epic’s sample and works in sessions originating from UEFN perfectly.

# defined globally outside of any classes
var RoundNumber:weak_map(session, int) = map{}
var BestCompletionTime:weak_map(session, float) = map{}
...
# defined inside my creative_device class
    var ThisRound: int = 1
    var TimeToBeat: float = 60.0
...
# code in my creative device called from 'OnBegin'
IncrementRound():void=
        set ThisRound = if (LastRound := RoundNumber[GetSession()]) then LastRound + 1 else 1
        if:
            set RoundNumber[GetSession()] = ThisRound
        set TimeToBeat = if (BestTime := BestCompletionTime[GetSession()]) then BestTime else 60.0
...
# BestCompletionTime set later in the same creative_device
      set BestCompletionTime[GetSession()] = HUDupdate.LastKillTime

When I launch a session from UEFN, the two session variables: ‘ThisRound’ (the int round-number) and ‘BestTime’ (a float representing the best-completion-time-to-date) work exactly as expected. The game ends, and when I hit “play” again, I keep all my session values. Perfection.

When I publish a private version and play a round in Fortnite, then hit “[R] Ready Up” to play again, there is no memory of my session variables. Both global variables are their default, round-one values for every game. And, I am not returning to the Lobby, I know everything will be lost then.

Anyone get their session variables working? The RoundNumber is an exact duplicate of Epic’s code with just variable name changes.

PS1 – I did my homework, I re-read Epic’s documentation on Global Variables and Weak Maps
PS2 – Do you have to restart games by some other way than using the built-in ‘Ready Up’?

1 Like

weak_maps are supposed to store variable during a single round, not between games or rounds. See session class “Type for which there is a single instance per round”
The docs say it could change in the future to one instance per game

This is actually a bug, see Verse Internal Error - #4 by im_a_lama

So I’m not sure what you’re trying to do exactly, but maybe using a custom round system instead would work better, if I understood correctly :+1:

SEE: Verse global variables no longer working, even on previous uploads
EDIT: I’m not sure about the fact that it resets between rounds, maybe someone can help me with that
EDIT2: If that’s the case, this is something they reverted, it used to work between rounds but not anymore, this is why the “official” sample is not working.

1 Like

Thanks, a lot of people are in my boat. I missed the big flurry of developers noticing the retraction of ‘GetSession()’ two weeks ago, so I ended up doing a lot of wasted work and making posts redundant to theirs.

1 Like