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’?