Getting Started
Creating A New Widget With Catchup Functionality
See W_ExampleHealthbar
for an example implementation.
Create a new
User Widget
class (User Interface → Widget Blueprint).Select
W_CatchupHealthbarBase
as the parent class for the widget.Add an
Overlay
widget.Add two
Progress Bar
widgets to the overlay. One will be the main progress bar, and the other will be the catchup progress bar.Select the main progress bar and ensure
Background Image
is set to draw as None.Bind the percent for the main progress bar to
Main Percent
.Bind the percent for the catchup progress bar to
Catchup Percent
.Ensure the catchup progress bar has a different fill color than the main progress bar so they can be distinguished from each other.
Adding Catchup Functionality To An Existing Widget
Open your widget and click Class Settings.
Change
Parent Class
toW_CatchupHealthbarBase
.Bind the percent for the main progress bar to
Main Percent
.Bind the percent for the catchup progress bar to
Catchup Percent
.
Adding A Healthbar To An Actor
See BP_NPC
and W_ExampleHealthbar
for an example implementation.
Add a
Widget Component
to your actor.Set
Space
toScreen
, setWidget Class
to your healthbar widget class, and setDraw At Desired Size
totrue
.In the
BeginPlay
event, callInitialize Values
. Make sure to setConsumer Will Manually Update?
totrue
, because screen space widgets don’t always receive tick events (e.g. when they’re offscreen) which can lead to odd behavior.In the
Tick
event, callManual Tick
. This way, we can be sure the widget always receives tick events.In the
AnyDamage
event (or whenever the current health changes), callSet Current Value
.
Adding A Healthbar To The Screen
See BP_Player
and W_ExampleHUD
for an example implementation.
Create a new widget or edit an existing one.
Add a healthbar widget to your widget.
If you’re using
W_ExampleHealthbar
for this step, setHide Healthbar When Full
tofalse
so the healthbar is always shown on the screen.Set
Is Variable
to true so the healthbar widget is accessible to Blueprints.In your player blueprint, create your widget and add it to the viewport.
In the
BeginPlay
event, callInitialize Values
. We can leaveConsumer Will Manually Update?
unchecked because the widget will always receive tick events when added to the viewport.In the
AnyDamage
event (or whenever the current health changes), callSet Current Value
.