Ninja Bear Studio Plugins Help

Track Enemy Attributes

Now that we created the first Combat Widget, let's create a more advanced one, the Overhead Info. It will be used with the enemy character, to show attributes and status effects.

This is an advanced topic, in a sense that will be leveraging many ways to use UMG Viewmodels, not just binding them directly to widget components, but creating functions to implement more interesting features.

Review your Enemy Attributes

  1. Open your Combat Attribute Data Table for the Enemy.

  2. Check the Health attribute, to ensure it has valid values.

Create the Enemy Overhead Widget

  1. Create a new widget, based on NinjaCombatBaseWidget.

  2. In the Designer tab, add a Vertical Box with a Text Block for the Damage, a Progress Bar for Health, another Progress Bar for the Stagger meter and a Uniform Grid Panel for Status Effects.

    Enemy Widget Design
  3. In the Widget Graph, create the following Variables:

    • LockedOnTarget: Boolean

    • AccumulatedDamage: Float

    • DamageTextTimerHandle: Timer Handle

    • AutoDisplayTimerHandle: Timer Handle

  4. Implement the Construct and Destruct functions, used to set initial visibility and clean-up timer handles.

    Widget Lifecycle
  5. Create two Custom Events, that will be implemented later: AddDamage and ResetDamage.

  6. Create a Custom Event, HideOverhead, that resets the damage and collapses the widget.

    Hide Overhead Event
  7. Create a Function, ShowWidgetFromIncomingDamage, that will show the widget when damage is received.

    Show Widget From Incoming Damage
  8. Create a Function, ResetState, that resets this widget when a new actor is selected.

    Reset State
  9. Create a Function, UpdateStatusEffects, that adds an icon from an active Gameplay Effect, with a valid Combat UI Data.

    Reset State
  10. Create a Function, SetTargetLock, that shows or hides the widget when the player is locking on this target.

    Set Target Lock
  11. Create a Function, SetCriticalDamage, that will set a different color for the damage block, when a critical hit occurs.

    Set Critical Damage
  12. Create a Function, SetDeathState, that will hide the widget when the enemy dies.

    Set Death State
  13. Create a Function, SetPoiseValue, that shows the Stagger Progress Bar when there's any ongoing value.

    Set Poise Value
  14. Create a Function, SetStaggerValue, that modifies the Poise Progress Bar when the enemy is staggered.

    Set Stagger Value
  15. With all the support functions done, implement the AddDamage and ResetDamage to accumulate and reset damage.

    Add and Reset Damage
  16. In the Viewmodels tab, add the following Combat Viewmodels, setting their Creation Type to Create Instance.

    • CombatVitals: Exposes the main combat attributes.

    • PoiseAndStagger: Exposes the poise state and stagger progress.

    • Damage: Exposes information about the last damage received.

    • StatusEffects: Exposes all active status effects, applied from Gameplay Effects.

    • TargetLock: Exposes the Current Target Lock state on this character.

  17. Bind the Combat Viewmodels to the correct properties and functions.

    Viewmodel Bindings

Update the Enemy Blueprint

  1. Open your Enemy Blueprint and add a NinjaCombatWidgetComponent to it.

  2. Adjust the proper location for this widget, probably placing it above the character's head.

  3. Set the Space to Screen.

  4. Set the Widget Class crated in the previous step.

Viewmodel Bindings

Test everything

  1. Press Play and attack your enemy, the overhead widget should show up and reflect incoming damage.

  2. Lock on your target and the overhead widget should also appear. Unlock and the widget should disappear.

  3. Notice how critical damage, poise damage, stagger state and status effects (if you have them) are displayed.

  4. The widget will also disappear when the enemy dies.

Last modified: 29 December 2024