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,
And this is the log that says what is loaded,
(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?
For saving the game i create my own SaveGame BP where i create this variables:
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:
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):
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.
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.
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…
Thanks for answering! Unfortunatelly, it still doesn’r work
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 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)
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’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.
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:
I implemented your approach to my particular case and now, when i start the game with the play button, i do this: