UE5 Modular Health Component
Hardcoding health logic inside every actor is a bad habit. It works for one object, then it becomes a mess the moment you need health on props, AI, players, destructible objects, doors, robots, or anything else in the world.
In this tutorial, you will build a reusable Health Component in Unreal Engine 5 using Blueprint Actor Components. The system handles damage, clamps health safely, calculates health percentage for UI, broadcasts updates through an Event Dispatcher, updates a world space health bar, and destroys the owning actor when health reaches zero.
This starts the Health and Destruction series and connects cleanly with the weapon system built in previous episodes.
Watch the video on YouTube: Modular Health System in Unreal Engine 5 Reusable Actor Component Blueprint
GitHub repository: AIUnreal on GitHub
Subscribe for more Unreal Engine tutorials: Rambod YouTube Channel
What You Will Build
- A reusable Actor Component for health logic
- A Receive Damage function with proper clamping
- A health percentage value for UI updates
- An Event Dispatcher for broadcasting health changes
- A base destructible actor using the Health Component
- A world space health bar widget
- Line trace damage integration from the weapon system
- Automatic actor destruction when health reaches zero
Why Use an Actor Component for Health?
The goal is simple: create health once and reuse it everywhere.
Instead of duplicating HP variables, damage functions, death checks, and UI update logic in every Blueprint, the health logic lives inside one reusable component. Any actor that needs health can receive the component.
This is the correct architecture for a scalable Blueprint project. If you copy-paste health logic into every actor, your project will become painful to maintain.
Step 1: Create the Health Actor Component
Open the Content Drawer, go to your Blueprints folder, right-click, and choose:
Blueprint Class > Actor Component
Name it:
BP_HealthComponent
An Actor Component does not exist as a visible object in the world. It has no transform. It simply adds reusable behavior to an actor.
Step 2: Add the Core Health Variables
Inside BP_HealthComponent, create these variables:
- HP as Float
- MaxHP as Float
- Died as Boolean
- HealthPercentage as Float
Floats are used for HP because they give more flexibility for fractional damage, scaling, regeneration, or future balancing.
HealthPercentage stores a normalized value from 0 to 1. That makes it perfect for progress bars.
Step 3: Create the Receive Damage Function
Create a new function named:
ReceiveDamage
Add one input:
Amount : Float
This function will receive incoming damage from weapons, explosions, traps, or any other damage source.
Step 4: Add the Health Changed Dispatcher
Create an Event Dispatcher named:
OnHealthChanged
This dispatcher broadcasts whenever health changes.
That is important because the Health Component should not directly control every widget, effect, sound, or destruction behavior. It should announce that health changed. Other systems can listen and react.
Step 5: Implement Damage, Clamp, and Death Logic
Inside ReceiveDamage, subtract the damage amount from current health:
HP - Amount
Then clamp the result:
Clamp Float
Min = 0
Max = MaxHP
Set HP to the clamped result.
Next, calculate health percentage:
HealthPercentage = HP / MaxHP
Then check whether the actor has died:
HP <= 0
Store that result in the Died Boolean.
Finally, call:
OnHealthChanged
Now the component updates its own internal state and broadcasts the result to anything listening.
Why Clamping Health Matters
Never let health go below zero or above max health unless you have a very specific reason. Negative health values create ugly edge cases, especially when UI, death checks, healing, or destruction systems depend on clean values.
Clamping gives the system predictable boundaries. Predictable systems are easier to debug.
Step 6: Create a Base Destructible Actor
Create a new Actor Blueprint named:
BP_BaseDestructibleObject
Add these components:
- Static Mesh
- Widget Component
- BP_HealthComponent
Select the Health Component and set:
HP = 100
MaxHP = 100
If these values are left unconfigured, the object may behave incorrectly or die instantly.
Step 7: Set Up the Mesh and Health Bar Widget
Assign a simple mesh, such as a cube, to the Static Mesh component.
Select the Widget Component and set:
- Space: Screen
- Draw Size: 100 x 20
Create a new widget, for example:
WBP_HealthIndicator
Inside the widget, set a custom size of 100 by 20, add a Progress Bar, rename it:
HealthProgressBar
and make sure Is Variable is enabled.
Step 8: Make the Static Mesh the Root
Drag the Static Mesh component onto the Default Scene Root to replace it as the root component.
This matters if you later enable physics or apply impulse. If the mesh is not the root, the mesh may move while the widget stays behind, which looks broken.
Making the mesh the root keeps the actor structure cleaner and prepares it for future physics and destruction behavior.
Step 9: Bind the Health Dispatcher in Begin Play
In BP_BaseDestructibleObject, open the Event Graph.
Drag in the Health Component and search for:
Assign OnHealthChanged
Connect this to Event Begin Play.
This tells the actor to start listening for health changes as soon as it appears in the world.
Step 10: Update the Health Bar When Health Changes
From the custom event created by the dispatcher, get the Widget Component and call:
Get Widget
Cast it to your health widget class, then access:
HealthProgressBar
Call:
Set Percent
and connect the Health Component’s:
HealthPercentage
to the percent input.
Now the widget updates automatically whenever damage is received.
Step 11: Destroy the Actor When Health Reaches Zero
From the Health Component, get:
Died
Feed it into a Branch.
If true, call:
Destroy Actor
For now, this is enough. Later, you can replace or extend this with destruction effects, sounds, particle systems, delayed destruction, or fractured meshes.
Step 12: Apply Damage from the Weapon Line Trace
Open:
BP_ThirdPersonCharacter
Find the existing weapon fire logic after the line trace, decal spawn, and hit validation.
Add a Sequence node so the existing physics impulse logic can continue on one branch while damage runs on another.
From the line trace Hit Actor, call:
Get Component by Class
Set the component class to:
BP_HealthComponent
Then check the returned component with:
Is Valid
If valid, call:
ReceiveDamage
and set the amount to:
10
Now any actor with the Health Component can receive damage from your weapon system.
Why Get Component by Class Is Useful Here
This is what makes the system modular. The weapon does not need to know whether it hit a crate, enemy, robot, prop, or destructible wall. It only checks one thing: does the hit actor have a Health Component?
If yes, apply damage. If no, ignore it.
That is clean and scalable.
Step 13: Test the Health System in the Level
Drag BP_BaseDestructibleObject into your level and place it where you can shoot it.
Press Play, pick up the weapon, and shoot the object.
You should see:
- health decreasing with each shot
- the health bar updating correctly
- the actor being destroyed when health reaches zero
If the object dies instantly, check the HP and MaxHP values on the Health Component. If the health bar does not update, check the widget cast and Progress Bar variable.
How the Full Modular Health System Works
- The weapon line trace hits an actor
- The character Blueprint checks whether the hit actor has BP_HealthComponent
- If valid, it calls ReceiveDamage
- The Health Component subtracts damage and clamps HP
- HealthPercentage is recalculated
- Died is updated
- OnHealthChanged broadcasts the update
- The actor updates its health bar
- If Died is true, the actor destroys itself
Common Mistakes to Avoid
- Hardcoding health logic into every actor
- Forgetting to clamp health values
- Not setting HP and MaxHP properly
- Forgetting to call the Event Dispatcher after damage
- Not enabling Is Variable on the progress bar
- Casting to the wrong widget class
- Trying to damage actors directly instead of checking for the Health Component
- Leaving the mesh as a child when physics movement should move the full actor
Why This Is the Right Base for Destruction
This tutorial does not just create a health bar. It creates the foundation for damage and destruction.
Once an actor has reusable health, you can later decide what happens when health reaches zero. Maybe it gets destroyed instantly. Maybe it fractures into pieces. Maybe it spawns particles. Maybe it drops loot. Maybe it alerts AI.
The Health Component should not care about those details. It only manages health state and broadcasts changes. That separation is the point.
Conclusion
In this tutorial, you built a modular Health Component in Unreal Engine 5 using Blueprint Actor Components. You created HP, MaxHP, Died, and HealthPercentage variables, implemented damage clamping, added an Event Dispatcher, built a base destructible actor with a world space health bar, and connected your weapon line trace to the health system.
This is a clean foundation for damage, destruction, AI combat, and reusable gameplay architecture.
Watch the full tutorial on YouTube: Modular Health System in Unreal Engine 5 Reusable Actor Component Blueprint
Subscribe for more Unreal Engine tutorials: Subscribe to Rambod on YouTube
Frequently Asked Questions
Why use an Actor Component for health in Unreal Engine?
Because it lets you reuse the same health logic across many different actors without duplicating variables and damage functions everywhere.
What does HealthPercentage do?
It stores health as a normalized value from 0 to 1, which makes it easy to drive UI elements such as progress bars.
Why use an Event Dispatcher for health changes?
Because it lets the Health Component broadcast updates without tightly coupling itself to widgets, effects, sounds, or destruction logic.
How does the weapon apply damage to any actor?
The weapon checks whether the hit actor has BP_HealthComponent using Get Component by Class. If the component exists, it calls ReceiveDamage.
Why does my actor die in one shot?
Most likely HP or MaxHP is not configured correctly on the Health Component.
Can this health system work for AI and players too?
Yes. Any actor can use this component, including props, AI enemies, player characters, destructible objects, and interactive world objects.
Continue Unreal Engine 5 Enemy AI Series – Beginner Blueprint Tutorials
Back to Unreal Engine 5 Enemy AI Series – Beginner Blueprint Tutorials playlist • Lesson 10 of 15