Skip to content

Combat Widgets

The system provides a few base widgets that can be used to display combat-related information.

Widgets can be used by both the Player, who's considered the Owner of the Widget (as usual) or hosted by the dedicated NinjaCombatWidgetComponent in an external character, such as an Enemy.

Event-driven or binding to values?

All widgets are event-driven and won't bind to any backend value.

Combat Widget Component and Combat Widget Interface

This NinjaCombatWidgetComponent extends the core WidgetComponent, and it's able to provde the component's owner to its Widget Instance, so it can access information about the actual "owner" instead of the Player that owns the Viewport.

This can be done to any widget that implements the CombatWidgetInterface. In which case, the Combat Owner will be assigned via the SetCombatActor function.

Base Combat Widget

Before getting into the actual widgets, it's important to mention that the system provides a base widget, the NinjaCombatBaseWidget. It's purpose is to implement the CombatWidgetInterface, while also providing ways to retrieve such Combat Owner, its Combat Component, and its Ability System Component.

The base implementation of the GetCombatActor will return either the Combat Actor set via interface or, in case this actor is null, the actual Owning Player Pawn.

The Combat Actor is propagated to the Widget Tree

By default, setting a Combat Actor to the Base Combat Widget will navigate the Widget Tree and propagate the new Actor to any Widget also implementing the CombatWidgetInterface.

Base Transient Widget

Introduces the ShowWidget and HideWidget events and manages the logic to hide the widget after a certain amount of time passes without refreshing the event.

Property Description
Hide when Unchanged If true, hides the widget if unchanged for a set amount of time.
Display Duration Time to display the widget after a change has been detected.

Base Overhead Bar Widget

Base widget that can be used as to display an overhead progress bar calculated from current and maximum attributes. It will bind to a ProgressBar component, which must be marked as a variable and named OverheadProgressBar.

There are a few properties that can be adjusted on each instance.

Property Description
Hide On Fatal Damage If true, hides the widget when the owner receives fatal damage.
Current Value Attribute Attribute to bind for the "Current Value".
Maximum Value Attribute Attribute to bind for the "Maximum Value".
Asynchronous updates

Updates from the attributes will be collected by connecting to their delegates, instead of attempting to collect potentially unchanged values on each frame.

Also worth of note, this widget provides two Blueprint Native Events:

  • UpdateStatus: Called when a changed on the current or maximum was received. By default, it will update the progress bar with the new value and invoke ShowWidget to actually display the widget if needed.

  • ShowWidget: When the widget is ready to be shown, this is the event responsible for doing so. It will simply set the the widget to visible, but you can do something more elaborate, such as playing an animation, like so:

Improving the Show Event

  • HideWidget: If set to be hidden on fatal damage or if unchanged, then this event will be responsible for it. It will simply collapse the widget by the default, but you can do something more elaborate, such as playing a Widget Animation, like so:

Improving the Hide Event

Make sure to call Parent Events properly

Especially for the ShowWidget and HideWidget events, make sure to invoke their "parent" counterparts as appropriate or ignore them if that's a deliberate decision and you have a reason to do so.

Overhead Health Bar Widget

This Widget extends the base NinjaCombatBaseOverheadBarWidget, displaying the owner's Health as a Progress Bar. By default, Health Attributes are collected from the provided NinjaCombatAttributeSet.

Overhead Stamina Bar Widget

This Widget extends the base NinjaCombatBaseOverheadBarWidget, displaying the owner's Stamina as a Progress Bar. By default, Stamina Attributes are collected from the provided NinjaCombatAttributeSet.

Overhead Magic Bar Widget

This Widget extends the base NinjaCombatBaseOverheadBarWidget, displaying the owner's Magic as a Progress Bar. By default, Stamina Attributes are collected from the provided NinjaCombatAttributeSet.

Damage Info Widget

This Widget can be used to display damage information from the FDamageEntry struct, which contains the damage applied and details about the hit, such as "Critical Hit", "Fatal Hit", etc. For more information on this struct, please check the Damage and Mitigation page.

By default, this widget has only one binding, to a TextBlock where the damage applied will be displayed. You can choose to either display the individual damage applied or the accumulation of damage that has been applied since the widget was shown, via the bAccumulateDamage property.

You can react to a damage event by implementing the UpdateDamage function, which will give you access to the Causer, Target and Damage Information. Here is an example on how you could implement this function to handle critical damage.

Overriding the Update Damage Event