Tuesday, April 16, 2024
HomeSample Page

Sample Page Title


				
					#embody "GameInstance_CPP.h"
#embody "SaveGame_CPP.h"
#embody "Engine.h"

void UGameInstance_CPP::Init()
{
	// examine if there may be recreation information to load it
	// or create a brand new one if the sport is simply beginning
	GameData = Forged<usavegame_cpp>(UGameplayStatics::LoadGameFromSlot(SaveSlot, 0));

	if(!GameData)
	{
		// create a brand new recreation information
		GameData = Forged<usavegame_cpp>(UGameplayStatics::
			CreateSaveGameObject(USaveGame_CPP::StaticClass()));

		GameData-&gt;PlayerLocation = FVector(0, 0, 0);
		GameData-&gt;Rating = 0;

		UGameplayStatics::SaveGameToSlot(GameData, SaveSlot, 0);
	}

}

void UGameInstance_CPP::SaveGameData(FVector PlayerLocation, int32 Rating)
{
	if (GameData)
	{
		GameData-&gt;PlayerLocation = PlayerLocation;
		GameData-&gt;Rating = Rating;

		UGameplayStatics::SaveGameToSlot(GameData, SaveSlot, 0);
	}
}

USaveGame_CPP* UGameInstance_CPP::LoadGameData()
{
	if (GameData)
		return GameData;
	else
		return nullptr;
}</usavegame_cpp></usavegame_cpp>
			



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments