Saving and reloading an integer?
I am kind of new here and am having serious difficulties getting something seemingly simple to function.
I have a variable thats set on my player character called TotalKills (integer) using an AddKill function call. This value is stored in a textbox on my players widget hud.
This is what I would like to have: The player will repeat playing various levels for a high score basically.
Every Tutorial, or forum post or ASK I come across does not work or is dealing with things I do not need like saving position or checkpoints and even trying to remodel those tutorials to work for me are failing miserably. Ive spent the entire weekend now failing like a pr0 noob :D
I do not want to use the Level Blueprint for this because i will have multiple levels and will add a scores page that shows scores from various levels to my main menu Statistics page.
Can I save the data to file.......from the characters blueprint Death Event (which calls my AddKill function too)........and have it reloaded from these 2 widgets that handle either RETRY or STARTGAME.
I dont know how to display the present level name either......
Can someone assist me on this?
asked Sep 06 '15 at 05:30 PM in Blueprint Scripting
I finally got this working by creating a function that handled the loading. I created another variable in my character called highscores.
The instance of the SaveGame_BP I made wasnt even necessary and didnt function as in Mamoniems tutorial at all. I could aojnly cast first then call that...which made no sense.
If anyone wants to see the final solution dont hesistate to PM me. I am sure many coiuld use it as none of the present tutorials work.
answered Sep 08 '15 at 01:28 AM
Saving data that should be persistent across levels is best done through the GameState class. It can be passed from map to map without being reset, and is accessible to all clients in a multiplayer game. Create your int variable there, and save your kills to the GameState :)
Actually saving the data between game restarts is a whole other beast, and I would suggest reading these articles: https://wiki.unrealengine.com/Save_System,_Read_%26_Write_Any_Data_to_Compressed_Binary_Files https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/
The first article is a touch more involved, but will result in a far more flexible system for you. The second one is more general-purpose, and can be done in only Blueprint.
answered Sep 06 '15 at 06:16 PM
You either follow that step by step tutorial I made about saving any data:
Or, you just make it easier for yourself, and purchase this tool from the market place, pretty cheap and save any thing within one node. And loads it with another one node!
answered Sep 07 '15 at 01:36 AM
Well if i am being honest, yours was one of the tutorials I began to follow and quickly realised it will not work with how I want things to function. plus, If got it right you are doing something completely illogical by saving by clicking the right moiuse button and also using the level blueprint........both are completely out of the question for my game. thank you however for posting it. Your easy save and load will not work with what I am doing :( I intend on having a great deal of integers saved once this initial set up is working.
for my purposes the only way to go, is the main menu UMG widget button option for saving and loading.
If someone could show me a widget to widget integer variable pass....(I am unable to castto any widget from another any other widget).......and pass a integer into a saved file........ then how to load it and pass it back into the widget it came from originally......i would be forever thankful. In my head that must be a 5 minute video.
Info: My character is able to pass to the hudwidget because my character BP opens that hud widget. if my other widget can get that number either from the character or from that widget and into my main menu widget and back into the hudwidget after loading .......we are win:D
answered Sep 07 '15 at 11:42 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here