I am a bit stumped. I looked at Tappy chicken example but i don’t feel its applicable and if it is i cannot translate what was done to what i need.
My setup is like this.
I have a HUD blueprint which opens the end of level interface displaying Next, Retry, and the current level score.
I have a save Game Blueprint.
A controller blueprint.
Then i have 3 pawns. Once one reaches the end of the level the game continues but you possess the next pawn. Each one has their own health variable value.
My HUD blueprint contains a Time value.
So what i want to achieve is the following.
Once the first pawn reaches the end, i want to get the current health value and store it.
Second pawn reaches i want to add that health value to the first. Repeat for pawn 3.
That should then create a value of combined health values.
Once the third pawn reaches the end, the level ends and the time stops and the menu comes up.
I want to then take the 3 health values and add it to the time value.
The result of all values combined is the score.
That Score must be stored and saved. Because if you load the game it should check what Level1 Level2 Level3 etc. score value is.
Those values determine if your level selection menu is displaying how many “stars” you unlocked.
I have tested the functionality of displaying things according to score etc.
My issue is i cannot understand where should i be placing my Health values and where i should be writing it to add them together on end of level.
I do not need spoon feeding. But i would really appreciate some guidance as to what to aim for. Because right now, i am not sure if i should be creating many variables like Level1Score, Level2Score etc. Or create an array and call those values from the array. Or even if it should be in a level blueprint, an actor blueprint or where to place them.
If anyone can point me in the right direction it would be much appreciated.
You should keep your health wherever you have it now, but then at the end of the level when you calculate the full thing into a Score, you do the part of the BP that’s in the separate box as shown in PattyM’s screen. You then feed the Score int from that level into the ‘Item’ of the ‘Set Array Elem’ for the Scores array as shown in the screen. Index is the level you want it saved for, I just have that in my HUD and set it through a cast in each level’s beginplay event to match the level number. Depending on how you have things set up, you may have to come up with a workable scheme to match.
Thank you. Finally got to the point where i could work on this.
I managed to save my stuff. I used the picture tutorials on Pattym’s Blog.
The only think i noticed is that if setting up the save system in the construction script then i get errors about cannot save due to external map source etc.
Moved the blueprint to normal even graph. Finally work.
I spoke to soon.
Still have an issue. Its seems that the save data is overwriting the entries.
I followed the Video tutorial now of @pattym but i cannot use a Level Blueprint system. Mostly due to not wanting to copy and paste stuff for every level i make.
Any advise would be very much appreciated.
This is my setup.
On begin play the Level Blueprint says I am Level “number” 1,2,3 etc.
In the HUD blueprint
Begin Play - Create save game object - Set SaveGameRef
Then another section that gets the current level, and saves it to the savegame.
“Set Array Elements” don’t work for cast to arrays. Save the cast to array to a variable in your had as a reference. You then set the index of the reference and proceed to set level score in your save game object to the reference variable.
Ok. Im not sure if i just did the exact same thing.
I am struggling to understand the concept of what is actually happening. Basicly the way i understand it.
I Cast to savegame. Get the Array. Set that Array to the reference array. Then set the reference item to the corresponding Index. Then Cast to savegame and set the array to the reference array. And save.
Which actually to me seems to be exactly what i did before but just a longer way of doing it with the same result.
It does save the current Index of the array but then sets all other index items back to 0.
Normally i dont like being spoon fed and i apologize for being a pain in the ***.
Hmm. So after adding some debugging stuff i discovered what the problem is exactly. But still unclear how to fix it.
When the Map is loaded, it checks what is the current value of the item in the array. It returns 0.
When the Map is finished after it calculate the value it checks again what that value is. Then it shows the correct value.
But every time i load the map or restart the map the value in the savedgame object is 0 again.
I also checked if the reference array is getting the values. It does.
But due to the savedgame array reseting on map load, it just sets the ref array back to 0 at the start.
So i am assuming its because its not actually saving the value. Its only updating the savedgame blueprint, but not retaining that value.
Thank you for your patience.
I started getting frustrated and decided to organize my blueprint better. While moving everything and commenting stuff, i noticed this small little event hidden between everything.
It was On Event Begin Play create save game Object.
That event basically reset my savedGame every time i started a level.
I deleted it, and now my savegame information is retained.