As we already have included the needed header files within the main game header file, we will be able to access the SaveGame
methods from anywhere.
So, within the AGladiator::OnChangeHealthByAmount(float usedAmount)
method of the player controller, I'll be adding a logic to save the health value any time it gets changed.
void AGladiator::OnChangeHealthByAmount(floatusedAmount) { TotalHealth -= usedAmount; FOutputDeviceNullar; this->CallFunctionByNameWithArguments(TEXT("ApplyGetDamageEffect"), ar, NULL, true); //A message to be printed to screen FString message; //Creating an instance of the bellz save class UBellzSaveGame* BellzSaveGameInstance = Cast<UBellzSaveGame>(UGameplayStatics::CreateSaveGameObject(UBellzSaveGame::StaticClass())); //Change the health value of the save class to match the current health value of the gladiator BellzSaveGameInstance->PlayerHealth = TotalHealth; //Store the health value to the save file...