Ive just implemented a ‘best time’ and ‘best score’ counters which save in my game just like how its done in the Tappy chicken game.
My problem here is when using more levels, i know i can make more variables in the save game BP for each level but how can i check which map is loaded so those certain variables are used and saved?
Is there a way of creating a branch to check which level is loaded? as at the moment that’s the only way i could think of doing it.
Hopefully I’m clear on what i mean but if not give me a shout any thoughts on how to do this would be cool
Ok so i made some progress on this, from the Level BP i just fired a custom event (Each level has its own custom event) from event begin play that goes to my BP with all my save stuff in which turns a branch on and then i just copy stuff for each level that i have.
So it works but its a bit crazy the amount of stuff ill have to copy for each map (And end up with one crazy BP).
If anyone suggests anything better just lemme know! …or if anyone wants to see how i set it up i can upload screenshots
What I did, just saving a ‘best time’ float, was use an array. In each level, I set an Int in my HUD that then I used as the Index for the array. This way, you don’t have much to do each level and the logic (at least for my setup) is in one place that’s always loaded (HUD).
Sorry for the slow reply, just saw this. Here’s what I’ve got:
Save game variables - I’m using the BestTime and BestTimeArray floats and BestTimeString and BestTimeStringArray variables in my HUD which is where I do all of the Save/Load functionality. The reason for a float and a string is to give me a more streamlined visual of the actual time that only has 2 decimal points.
OnBeginPlay - I’m running through to see if the save game already exists and if not, creating one. In there I set the arrays based on the solo string and float defaults. The LevelInt is just an int that I cast to HUD in each level’s level BP and set to the level number. This gives me the index that’s then used for each level to save a best time. I can also use that to decide what level to load on death or level completion (shown below)
BestTimeUpdate - Here I’m checking the time the level was finished in (called when level is successfully completed), comparing to saved best time and then updated. I also set a bool to tell my HUD to show a message announcing a new record was set.
End Level Options - If the player dies, I used the currently set LevelInt to reload the same level again. All my levels are named the same with just the number after the _ being different to make it easy to keep track of. In the level BP for each level, I set the LevelInt to the level number and that’s all I really need to do. If the player successfully completes the level I load the level called LevelInt+1. Simple.
Let me know if you need any additional info on anything. Hope this helps.