Download

Save System

Hello fellow devs, I’m here once again to ask for your support

I’m trying to develop a save system where i save player position, the player keys, the player coins, player rotation, coins in scene, keys in scene, enemies in scene and all the positions of the coins, keys and enemies.

What i do is simply using the save system in unreal editor to save it to a gameslot and then load it form that same game slot. The problem is that it seems to save to the slot and load from the slot, but it doesn’t actually “load”. Here’s what i mean:

Here is the log that says what is saved,

saved.jpg

And this is the log that says what is loaded,

loaded.png

(this logs are not from the same scene as the video, in this one there’re just enemies)

But as is seen in the video the coins doesn’t appear on the HUD, the player doesn’t stay in the same position as saved and the coins and keys aren’t preserved.

Why is this happening? I don’t really find no answer to this question anywhere in the internet, maybe because it’s quite an specific problem.

Could the position be conditioned by the player start component? That could do for the position, but what about the many other things?

You need to show your save and load code, that’s where the error is…

Hey, thanks for answering!

For saving the game i create my own SaveGame BP where i create this variables:

1.png

For saving the game, I’ve created multiple funcions that store the information and then i save them to the slot. I’ve added an input to each function that is a reference to my SaveGame_BP.

Here’s what the main save and load functions look like:

This is my function for saving coins and loading (i do the same with the keys):


This is my function for saving the position of the coins (i do the same with the keys and the enemies):


This is how I save and load the player position:


And this is how I save and load the player rotation:


I haven’t added the function that i use for saving the level because they work just fine.

I have the save function in my Character blueprint but I call it from the pause menu casting the player. That’s because I’ve also created an autosave function, and i couldn’t make it work form the pause menu nor cast the pause menu from the player to do it in the Character BP.

I have and call the load function from the MainMenu BP, using an onClicked Event (when the playe hits the play button, if there’s an existing game in a slot, it charges it):

And that’s pretty much my Save System. I hope I’ve explained everything well enough!

Well, first thing right out of the gate I’m noticing, is that your save game function always creates a new save game. You only need to do that if there isn’t one already there. You’re basically overwriting the game every time.

Is that any use, or shall I look further?

Thanks for your response!

I didin’t noticed that, could it really affect the performance of the load system tho? It’s my first time doing a save system with unreal and I’m kinda lost.

Well, it’s not affecting the performance, but it’s overwriting your game every time you save anything, that’s why it’s not working ( I think )…

Try this:


EDIT: ( again ). I don’t think I was clear. Yes, obviously when you save you need to overwrite the savegame, but you’re overwriting it with an empty one every time… :slight_smile:

Thanks for answering! Unfortunatelly, it still doesn’r work :confused:

It saves everything and loads everything but the information that loads still doesn’t “show” to the screen (player sitll don’t move to the loaded player position nor rotaion, coins doesn’t appear on the HUD counter, enemies still alive…)

What else could it be?

Ok, let’s concentrate on just player position, can you show me the code for LoadPlayerPosition?

Sure! Here it is

10.png

What I’m doing here is just casting to the player and setting its position to the position saved in my custom SaveGame BP (which is the input of the function)

Right try the same thing, but set the location of the pawn, not the controller. Tell me what happens…

It shows me a bucnh of “accessed none” errors:

You only need to change the bit that sets the player location. Instead of setting the controller ( because a controller doesn’t really have a location ), you just need to set the location of the player pawn. So just change the bit of BP ( above here ) to set the player pawn. Nothing else should be affected.

I can’t get to make it work either, this is how i tried to implement it:

Does this follow your idea or is it an absolutelly diferent concept?

I’ve written an example for you. It just deals with player location, get one thing sorted first, then add the rest. It doesn’t need to be on a timer, it could be in a menu or when the player hits a volume etc.

Part 1:


Part 2:

Also attached here. It’s a text file, just open it in any text editor, copy all, go to your level BP and paste.
SavePlayerPosition.txt (80.1 KB)

Just make a new level and put this in the level BP. Every time you stop playing and start again, it will put the player back where they last left off.

Tell me how you do :slight_smile:

It still doesn’t work but now it has a different error! Hahaha see, it loads a different position that the saved one. I know it for the logs, here are the logs:

15.png

I implemented your approach to my particular case and now, when i start the game with the play button, i do this:

And when i save i still cast the player from the pause menu but the saveGame function looks like this now:

Where could the problem be?

All it means is you didn’t save the game when you thought you did.

I can’t do any more I’m afraid. Put just what I showed you in a new level, it works, you can see it working.

Then incoporate it into your save system.

Once you get it, everything else will be a doddle.

I can’t seem to make it work, but i’m really thankful for your help and for dedicating your time to this!