Accessed none trying to read property ( and saving system problems )

Hello, im making save system for my game. I built code using tutorial from YouTube, but it was only about saving location on specific level. I got a problem that when im teleporting to other level i get the same location it saved before on past level and i spawn in the bottom of level (in void). Also i get error i mentioned in name of question, i want to fix it too.

More images

Hi,

First, you will not be able to set the player transform before opening the level, even after you fix your issues. When you open a new level in Unreal, most actors get destroyed (including your player pawn) and new ones get spawned in the new level. This is why setting the location before opening the level will not work.

You have 2 solutions:

  1. Either load the save game to get the name of the level, load the level, then on the BeginPlay of your player controller / pawn, load the save game again and set the position,
  2. Or use the GameInstance class to manage your save file.

The GameInstance exists for the whole duration of the game. It doesn’t get destroyed / respawned after each load of a level.

First, saving:

If you want to keep this save object, you can save it into a variable (in your GameInstance class, for example), but you don’t have to.

Then, in another play session, from the game menu for example, you may want to load this save to open the correct level:

On the Begin Play of your controller or pawn class, you can then check the same save file, to load the transform. This happens after the level has been loaded:

Again if you don’t want to have to load the file twice, you can do it once and save all the data / save game to your GameInstance.

1 Like

(post deleted by author)