Load Health from save

This commit is contained in:
baz 2024-05-27 20:33:38 +01:00
parent ee9718e9e3
commit 0e9a36f1c9
1 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,8 @@
#include "NakatomiCharacter.h"
#include "NakatomiCMC.h"
#include "NakatomiGameInstance.h"
#include "Kismet/GameplayStatics.h"
// Sets default values
ANakatomiCharacter::ANakatomiCharacter(const FObjectInitializer& ObjectInitializer) : Super(
@ -30,6 +32,15 @@ void ANakatomiCharacter::BeginPlay()
SetInventoryToDefault();
NakatomiCMC = Cast<UNakatomiCMC>(GetCharacterMovement());
if (UNakatomiGameInstance* gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
{
if (UNakatomiSaveGame* Save = gameInstance->GetSaveGameObject())
{
//TODO: More loading here
GetHealthComponent()->SetCurrentHealth(Save->PlayerHealth);
}
}
}
// Called every frame