Glaze of
Glory

This was an introductory project that I and 4 others worked on using the Unreal engine at Future games. It was used to introduce source control and group work dynamics. Additionally, it was also a good opportunity for me to put into practice what I had previously learned in UE4. In this project, I worked on the jump mechanics as well as the game-saving.

Save Game

The game was in need of a saving system to save high score, money and the equipment of the player. I took this upon myself as I Jave previously only done this in blueprint (drag and drop programming) and thought it could be good to translate that knowledge into C++. I encountered very few problems when creating this system, most of which stemmed from my inexperience within the engine, the biggest problem I had when developing this was that I was looking at the wrong place. I was certain that the fault laid in the saving and loading function when it in fact was the variables where I saved my score that wasn’t of the right type.


void USavedGameDataManager::LoadGame()
{
	if (UGameplayStatics::DoesSaveGameExist("testing", 0))
	{
		SaveGameInstance = Cast(UGameplayStatics::LoadGameFromSlot("testing", 0));
		Score = SaveGameInstance->Score;
		Equipments = SaveGameInstance->EquipArray;
	}
	else
	{
		SaveGameInstance = Cast(UGameplayStatics::CreateSaveGameObject(UGlazeOfGlorySaveGame::StaticClass()));
		UGameplayStatics::SaveGameToSlot(SaveGameInstance, "testing", 0);
	}
}

void USavedGameDataManager::SaveGame()
{
	if (UGameplayStatics::DoesSaveGameExist("testing", 0))
	{
		SaveGameInstance = Cast(UGameplayStatics::LoadGameFromSlot("testing", 0));

		if (Score - SaveGameInstance->Score > SaveGameInstance->HighScore)
			SaveGameInstance->HighScore = Score - SaveGameInstance->Score;
		
		SaveGameInstance->Score += Score- SaveGameInstance->Score;
		SaveGameInstance->EquipArray = Equipments;
		
		UGameplayStatics::SaveGameToSlot(SaveGameInstance, "testing", 0);
	}
}								
								

Air maneuvering

The game was in need of air maneuvering system to fight enemies and give the player an easier time to move in the level. As I’ve had my experience of managing movement in blueprint, I thought that this would be a good idea to move over to C++ and try it there as well. The jet pack and its functions were easy enough to finish, so I decided to try to spice it up by adding a fueling system that dictate when and how much the jet pack could be used.


void ACppDonutCharacter::JetPack()
{
	if (GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Falling)
	{
		if (bShouldPack)
		{
			if (!(CurrentFule <= 0))
			{
				LaunchCharacter(FVector(0, 0, 10), false, false);
				CurrentFule = CurrentFule - 0.4f;
			}
		}
	}
	else
		ThrustDelay = 0;

	if (!bShouldPack)
	{
		if (CurrentFule < MaxFule)
		{
			CurrentFule = CurrentFule + 0.3f;
		}
		else
			CurrentFule = MaxFule;
	}
}
void ACppDonutCharacter::JetStart()
{

	if (GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Falling)
		bShouldPack = true;

}
void ACppDonutCharacter::JetStop()
{
	bShouldPack = false;
}
void ACppDonutCharacter::Thrust()
{
	if (GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Falling)
	{
		if (CurrentFule > 0.f)
		{
			if (ThrustDelay < GetGameTimeSinceCreation())
			{
				FVector ThrustVelocity = FVector(0, 0, 0);
				ThrustVelocity.Z = (500.f * (CurrentFule / MaxFule)) + 500.f;
				LaunchCharacter(ThrustVelocity, false, true);
				CurrentFule = 0;
				ThrustDelay = GetGameTimeSinceCreation() + JetpackCooldown;
			}
		}

	}
}