x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Need Help Saving High Score Float Variable (Blueprints)

I am making a game in the RollingBall gamemode, and I have a scoring system setup that is showing your current score on your HUD and then when you "die" this menu pops up and it displays what score you just got and your all-time high score. I'm pretty sure all I need saved is the high score value. I have everything setup working great except it keeps reseting the high score back to default value (0) everytime I either hit the restart button on the in game menu or stop and play in the editor. So when you "die" the high score always shows the same as the current score (I have it setup using "if current score is greater than high score use current score to set high score* maybe thats the problem?) I have tried for weeks to get save game objects to work but nothing will... Please help. Oh, PS, these variables are floats if that helps any & both "scores" are default value 0.

Product Version: UE 4.14
Tags:
more ▼

asked Jan 11 '17 at 02:28 PM in Blueprint Scripting

avatar image

FyrxStudio
42 2 4 10

avatar image Erasio Jan 11 '17 at 04:30 PM

What does your saving and loading code look like?

Do you actually properly save the savegame object after changing the variable?

And load it before you read it?

avatar image FyrxStudio Jan 11 '17 at 05:48 PM

Well right now it's jumbled and trash, I've tried like 6 different ways and nothing has worked. And I don't know about the other stuff I don't have a way of testing that

avatar image FyrxStudio Jan 11 '17 at 05:49 PM

In the save games folder that it saves to automatically it did create the file but still doesn't work properly

avatar image Erasio Jan 12 '17 at 11:15 AM

Read through all of this:

https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/

Implement the blueprint version (there's a link to a guide at the bottom). If you still have trouble afterwards.

Update this question to show the code you have and try to describe the specific issue. Which part isn't working? Check if everything is being executed, etc.

A list of useful tools for debugging (so you can track down where exactly your issue is) can be found here:

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Debugging/

avatar image FyrxStudio Jan 12 '17 at 03:55 PM

Okay, I tried to get screenshots of everything that has anything to do with this. The part that is not working is it is not keeping the value of my high score float var after a level reset/load. It always displays the high score as the same number as the current score.alt text

alt textalt text

alt text

alt text

load save 2.png (164.4 kB)
load save 1.png (182.9 kB)
save game 1.png (202.6 kB)
save game 2.png (119.7 kB)
avatar image Erasio Jan 12 '17 at 05:19 PM

First of all. You need to create the savegame outside of the savegame object.

While it doesn't exist, there's no way for you to use that code.

Secondly. Your savegame is by definition not your ball / character. A cast is only asking if the input "Object" is of the type X in "Cast to X". Your newly created savegame is definitely not your ball meaning everything behind the cast won't be executed.

Third. You do not need to create a savegame object before loading. As the documentation says that's only done in this example, so the savegame exist.

In actual code you check whether it exists with "Does Savegame Exist". If not, there's nothing to load. Maybe you want to create one so for future reference or when you want to save something in the future. If it does, then you load it.

I would suggest storing a savegame variable in your player controller or player character. Have the code in the same class and only use the savegame variable for your highscore. There is no need to have a "highscore" variable in your character and copy it over all the time between the two.

avatar image FyrxStudio Jan 12 '17 at 07:03 PM

So I don't need anything in my Save Game Object? And where do I start the load from slot at on the load from slot node? and do the load from slot and create save game objects need to be connected to anything like on event begin play or anything to get them to execute? Sorry Im pretty noobie at this saving thanks for all the help!

avatar image FyrxStudio Jan 12 '17 at 07:13 PM

Okay, sO update after doing what you said as best as I could, I got it saving and at least finding the save (according to print strings) But it still is not actually saving the right data or something cause my high score is still showing the same as the current score.

avatar image silverfish1000 Jan 20 '17 at 04:07 PM

Did you get it to work? I have the same problem. How ever I run all my Coin Count Text Widget trough Game instance. Unfortunately the coins are constantly adding. So previousy collected coins and current coins nothing but adding together. I was wondering how would you tell the Game instance to only replace current Coin Count if X is greater then Current High Score and do nothing if X is lower then the High Score.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question