Saving character position

I tried to make a triggerbox (checkpoint) to save player position. I created a Mysavegame blueprint, triggerbox and a widget (MainMenu) to load game. When i try to save game it works well (or it seams to) but when i click on play button nothing happens.

This is my triggerbox (checkpoint):

And this is widget blueprint with loading button:

Hi ,

It looks like you aren’t actually saving a vector to SaveGameInstance. In your SaveGame BP, include a Vector variable. Then, when you cast to SaveGameInstance you’ve created, set its Vector variable as well. Then Save Game to Slot. When you load game, you can then get its Vector variable and send it to Character.

Here’s an example of how I have this set up:

Checkpoint Actor (an Actor Blueprint with a Box Collision component):

In my Controller (you can easily use this in your Widget and then cast to Character instead):

Hope that helps!

I tryed, saving part seems to work ( File_A has been created, and i put a print string at end of process to be sure) but whenever i try to load still nothing happens… i tryed to do it on character too (just like u did) but still nothing… could it be couse main menu widget is a level and character is in another one? and if it’s so how can i fix it?!

This is my saving checkpoint: [alt text][1]

This is my main menù blueprint (placed in a specific MainMenu level):

And this is how i tried to copy your blueprint directly in mycharacter:

Nothing works…

Oh, yes, Load would need to be performed in Level that you want that data. So after you move from Main Menu map to game’s map, then you can load that data and pass it to player. If you try to set Actor Location in Main Menu, it won’t know what to do with that information, and then opening next level won’t know of any changes you made in Main Menu level.

So i would have to first make menu open level i want and then load everything?! So each checkpoint needs to be customized to load level in which it is located, am i right? Is everything else in main menu blueprint right?

Well, what you can do in this case is save two things in SaveGame when your player hits Checkpoint: vector and name of level player is in. Then in your Main Menu, you load SaveGameInstance and get Name variable, and feed that into OpenLevel node. Then once level is loaded, load SaveGameInstance again and move character to vector you saved. As long as you don’t overwrite save data between those actions, that should work fine.

I tried to put a normal open level (with remove from parent) before loading but only thing my load button does is opening level without taking character to checkpoint destination (where i saved)
This is checkpoint:

This is first part of loading button blueprint, when i open level:

And this is loading part (that doesnt work at all):

You’ll need to do this somewhere other than Main_Menu widget, because that’s being unloaded along with everything else after Load node runs. Instead, you can put this in Character BP, GameMode, or even Level Blueprint, depending on how your project is set up; create a function that loads save game, gets vector, and moves character, and call it on Begin Play or Post Login. key thing is it needs to be in something in Level you just loaded.

I tried and tried but cant solve my problem… could you please explain me exactly how to do it?

I tried to give a boolean (true) if you click load button, then i put inside level blueprint a branch and if load button has been clicked it should load character in checkpoint position… but it isnt working!

I just noticed where exactly process stops… what should i put in object node of main menu?

Process Stops because Cast is failing. You are not casting to anything there. It asks you to chose as “Select Asset”. You need to chose either asset or make a variable about it reach out later.

Hi ,

I’ve gone ahead and created a small project that you can reference. It’s too big to attach, so I have it in my Google Drive:

https://.com/

What it does is simple, and you may need to adjust how it works in your own project, but basic idea should work in any project. It starts in a MainMenu level with a simple widget. button only does an Open Level. Technically it isn’t necessary to include it in this example, but I wanted to show you how it works in a multi-level scenario.

There’s a Checkpoint BP in level up stairs. If you touch it, it saves MyCharacter location to MySaveGame (which has a vector variable for this). Then you can quit game. Next time you load level from Main Menu, MyPlayerController loads MySaveGame and gets vector variable, and sets its location to that on Begin Play.

Let me know if you have any questions.

My only problem is that so i cannot differenziate play button from load one… So i tryed to make a boolean (clicked load) and it works but i get an error:

What could cause it?

If you’d like, you can upload project somewhere like Dropbox or Google Drive and get me a download link, and I’ll take a look at project. You can send it privately via PM on forums, if you’d prefer:

I’m uploading project, only thing you have to do to get error is to load “Livello_1” level inside “Livelli” folder and click play… you’ll get same error i got in screenshot.

https://.com/open?id=0BwmPd-rNtaDNfmJhVEl5b1NWMng1ckNlNlVzb1pfX2ZZd0VJTmlhY202TzdFYUxISFczU2c&authuser=0

if link doesnt work try with this one:

https://.com/folderview?id=0BwmPd-rNtaDNfmJhVEl5b1NWMng1ckNlNlVzb1pfX2ZZd0VJTmlhY202TzdFYUxISFczU2c&usp=sharing

Okay, I understand what you’re trying to do. I’ve updated my project to have this functionality as well, and here’s new link:

https://.com/file/d/0Bwuk9D3N4wZ4a25tMlBiZ0RINVE/view?usp=sharing

If yours is working except for that error, you can just ignore error for now. There are some Accessed None errors that don’t mean anything, and this may be one of them. However, I wouldn’t run this in Level Blueprint (as it’s harder to access) and you’re not really grabbing values from SaveGame in a reliable way.

Take a look at project I linked and you’ll see I have Main Menu widget saving bool value, and character loads save game and checks whether it’s true before setting character’s location.

Hope it helps!

I found what wasn’t working, it was a missing link in checkpoint between “cast to mysavegame” and “save game to slot”. Now i put loading in character controller and it should be easier to load on any level. Thanks a lot!