A third-person warrior game built in Unreal Engine 5 with C++ and Blueprints. The project covers a broad set of gameplay systems implemented entirely in C++: character movement and stamina management, melee combat with weapon equipping, AI-driven enemies, a variety of pickups and interactive world objects, UMG-based HUD, and a full save/load system. Blueprint subclassing is used exclusively for asset configuration and designer-facing event implementations.
The Player Character is built on ACharacter with a spring arm and camera setup. Movement input drives a four-state stamina machine — Normal, BelowMinimum, Exhausted, and ExhaustedRecovering — that controls whether sprinting is allowed and how fast stamina drains or recovers each frame. Attacking plays one of two randomly selected sections of a combat montage, and auto-focus interpolates the character’s rotation toward the active combat target during the attack.
The Weapon System is built around AWeapon, which extends the base AItem class:
- Equipping attaches the weapon’s skeletal mesh to the character’s
RightHandSocketviaUSkeletalMeshSocket, disables idle particles, and sets the weapon instigator to the player’s controller for kill attribution. - A
UBoxComponent(CombatCollision) is enabled and disabled from anim notifies during the attack montage. On overlap with an enemy it applies damage viaUGameplayStatics::ApplyDamageand spawns hit particles at theWeaponSocket. EWeaponStatetracks whether the weapon is lying in the world waiting to be picked up or is currently equipped. Multiple weapon types are supported through Blueprint subclasses.
The Enemy AI is driven by AAIController and two detection spheres on AEnemy:
- A large agro sphere (600 units) triggers
MoveTowhen the player enters, and stops movement when the player leaves. - A smaller combat sphere (75 units) schedules attack montages with a randomized timer between
AttackMinTimeandAttackMaxTime. AUBoxComponentattached toEnemyWeaponSockethandles hit detection against the player during the montage. - On death, all collision volumes are disabled, the death montage plays, the mesh is frozen via
bPauseAnims, and the actor is destroyed after a configurable delay. The player’s combat target is updated immediately so the HUD health bar hides correctly.
The Item Hierarchy provides a composable base for all world pickups:
AItemmanages a sphere collision root, idle yaw rotation, overlap particles, and sound. Subclasses overrideOnCollisionVolumeBeginOverlapto define pickup behavior.APickupItemfires aBlueprintImplementableEvent(OnPickup) on player contact and immediately destroys itself, letting designers implement the effect — health restoration, coin increment — entirely in Blueprint.AExplosiveItemapplies direct damage to both the player and enemies on overlap usingUGameplayStatics::ApplyDamage, triggers the parent’s overlap particles, then destroys itself.
The Floor Switch and Floating Platform cover interactive world mechanics:
AFloorSwitchraises a door when the player steps on a trigger box and closes it afterDoorSwitchTimeseconds once the player leaves.RaiseDoor,LowerDoor,RaiseDoorSwitch, andLowerDoorSwitchareBlueprintImplementableEvents driven by Blueprint timelines, withUpdateDoorLocationandUpdateDoorSwitchLocationas C++ callbacks.AFloatingPlatformlerps betweenStartLocationandEndLocationusingFMath::VInterpTo.EndLocationis authored in local space via an editor widget handle and converted to world space atBeginPlay. The platform pauses at each endpoint forInterpTimeseconds before reversing.
The Spawn Volume (ASpawnVolume) is a box-shaped actor that randomly selects a class from a designer-configured array and places it at a random point within its extent. If the spawned actor is an AEnemy, SpawnDefaultController is called manually and the resulting AAIController is wired to the enemy — necessary because characters spawned mid-game via SpawnActor do not have their controller created automatically. SpawnOurActor is a BlueprintNativeEvent so Blueprint subclasses can override the spawn logic.
The Save/Load System serializes full character state into UMainSaveGame:
- Saved data includes health, stamina, coin count, world transform, and the equipped weapon’s name.
- On load, the weapon is restored by looking up its name in an
AItemStorageactor — a designer-configuredTMap<FString, TSubclassOf<AWeapon>>placed in the level — spawning the class and equipping it to the character. LoadGameNoSwitchrestores stats in-place without triggering a level transition.LoadGameadditionally callsSwitchLevelif the saved level name differs from the current map.
The HUD and Player Controller (AMainPlayerController) manage three UMG widgets created at BeginPlay: the main overlay, the enemy health bar, and the pause menu. The enemy health bar is projected from the combat target’s world position to screen space each tick via ProjectWorldLocationToScreen, avoiding a widget component on the enemy actor. The pause menu toggles FInputModeGameAndUI and FInputModeGameOnly along with cursor visibility. DisplayPauseMenu and HidePauseMenu are BlueprintNativeEvents for Blueprint override.
Leave a comment