Section 7: Game Interface
In this section, we took the time to add an interface for our player and enemy to provide feedback to the player.
Section Intro - Game Interface
There are no notes for this lecture.
Designing the Player UI
There are no notes for this lecture.
Pure Blueprint Functions
In this lecture, we learned how to define a pure blueprint function. Pure functions do not modify the class variables it belongs to. Therefore, these functions can be called at any time without an execution pin. To define a pure function, you must add the BlueprintPure specifier.
UFUNCTION(BlueprintPure)
float GetStatPercent(EStat Current, EStat Max);The function will look like this in the blueprint event graph.

Updating the UI With Events
In this lecture, we created a set of events for when the health and stamina are updated. Here are the event definitions for them.
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(
FOnHealthPercentUpdateSignature,
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(
FOnHealthPercentUpdateSignature,
UStatsComponent, OnHealthPercentUpdateDelegate,
float, Percentage
);
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(
FOnStaminaPercentUpdateSignature,
UStatsComponent, OnStaminaPercentUpdateDelegate,
float, Percentage
);Next, we defined variables for storing the event's functions.
UPROPERTY(BlueprintAssignable)
FOnHealthPercentUpdateSignature OnHealthPercentUpdateDelegate;
UPROPERTY(BlueprintAssignable)
FOnStaminaPercentUpdateSignature OnStaminaPercentUpdateDelegate;Lastly, we just broadcasted these events in various areas of our component. Specifically when the health is reduced, stamina is reduced, and stamina is regenerated. Here's one example of how we broadcasted the event.
OnStaminaPercentUpdateDelegate.Broadcast(
GetStatPercent(EStat::Stamina, EStat::MaxStamina)
);Fixing the Enemy’s Target Reset
There are no notes for this lecture.
Designing the Enemy UI
There are no notes for this lecture.
Finishing the Enemy UI
There are no notes for this lecture.
Widget Animations
There are no notes for this lecture.
Playing Widget Animations
In this lecture, we created a new event for when the health stat is reduced to 0. Unlike the other events we created for the stats component, this event does not send any data. To create an event that doesn't supply data, we must use the DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE macro.
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(
FOnZeroHealthSignature,
UStatsComponent, OnZeroHealthDelegate
);Next, to broadcast the event, we must check if the health is actually 0. We performed this check during the ReduceHealth() function.
if (Stats[EStat::Health] == 0)
{
OnZeroHealthDelegate.Broadcast();
}Lastly, we took the time to play the widget animation and then waited for the animation to finish before proceeding to reload the current level.

Last updated