Character Movement and HUD

1 minute read

MedievalCombatProject

HUD

HUD for the Player. Has a Health and Stamina bar (Magicka will be added soon) and a Coin count(Will be moved to Inventory Menu).

The Health bar will will show changes when the Character takes damage or heals themselves.

The Stamina bar shows changes when the Character sprints or successively blocks an Enemy’s attack.

Movement

Movement of the Character uses a 1D BlendSpace for gradually changing from Idle to Walk to Run Animations, depending on the speed of the Character.

A function bCanMove determines if the Character is allowed to move or not. The MoveForward and MoveRight functions execute their contents only when bCanMove returns true.

bool AMain::bCanMove(float Value)
{
	if (MainPlayerController)
	{
		return (
			(Value != 0.0f)		// If Value to move is 0
			&& (!bAttacking)	// If Attacking
			&& (MovementStatus != EMovementStatus::EMS_Dead)	// If not Dead
			&& (!MainPlayerController->bPauseMenuVisible)		// If Pause Menu Visible
			&& (!MainPlayerController->bInventoryMenuVisible)	// If Inventory Menu Visible
		);
	}
	return false;
}

In Action

  • While Unarmed and not in Combat Mode
  • While Unarmed and in Combat Mode
  • While Armed with a One-Handed Weapon
  • While Armed with a Two-Handed Weapon(OLD) (Bug: Character rises above the ground. Will be patched soon.)Fixed 28/07/20
  • While Armed with a Two-Handed Weapon (NEW)

Sprinting

When the Player presses the Shift key while the Character is moving, the Character will start sprinting. This sprinting lets the Character move faster at the cost of using up Stamina by an amount StaminaDrainRate every second.

Once the Stamina gets depleted, the Stamina Bar will turn red and the Character will not be able to sprint till the Stamina regenerates to a value greater than MinSprintStamina, ater which the Stamina bar turns green again. I plan to add a pulsing effect soon.

You can view the code of the project here!

In Action

  • Sprinting while Unarmed
  • Sprinting while Armed