Save/load game problem


iam trying to save/load game but my actor location is 0, 0, 0 (LoadGameInstance->PlayerLocation) when i saved location for example 1000, 400, 400…
I tried 3 tutorials for savE/load but same result

void AMyCharacter::LoadGame()
UMySaveGame* LoadGameInstance = Cast<UMySaveGame>(UGameplayStatics::CreateSaveGameObject(UMySaveGame::StaticClass()));
LoadGameInstance = Cast<UMySaveGame>(UGameplayStatics::LoadGameFromSlot(SlotName, 0));

void AMyCharacter::SaveGame()
UMySaveGame* SaveGameInstance = Cast<UMySaveGame>(UGameplayStatics::CreateSaveGameObject(UMySaveGame::StaticClass()));
SaveGameInstance->PlayerLocation = RootComponent->GetOwner()->GetActorLocation();
UGameplayStatics::SaveGameToSlot(SaveGameInstance, SlotName, 0);

Am i doing something wrong please?

Thankyou for any advice.

I was trying something like that and discovered the PlayerStart would be what you have to change.

I load the location and rotation as you do, only I did it in GameMode’s overridden ChoosePlayerStart_Implementation. Then within that routine I spawn the PlayerStart (APlayerStart) with the location and rotation I’d saved. Then you return the pointer to that spawned APlayerStart and the player appears there.

I don’t have the code on this computer but could post it if you need it.

If you don’t, or don’t want to, use PlayerStart, then you can ignore this. But if you are using PlayerStart, this works.

I believe he already found the solution. He was missing the UPROPERTY from the variable.