Ninja Bear Studio Plugins Help

Track Player Attributes

The combat system provides Viewmodels to support your user interface. Let's get started with that topic, by creating some progress bars that will track the player's main attributes: Health, Stamina, and Magic.

Review your Player attributes

  1. Open your Combat Attribute Data Table for the Player. This was configured before, while configuring GAS.

  2. Check your Health Stamina, and Magic, to ensure they have valid values.

Create the Player Attributes Widget

  1. Create a new widget, based on NinjaCombatBaseWidget.

  2. In the Designer tab, add a Vertical Box and three Progress Bars, with Size boundaries.

  3. In the Viewmodels tab, add a ViewModel_CombatVitals entry. In the Details panel, set the Creation Type to Create Instance.

    Widget Design
  4. In the View Bindings tab, set the following bindings

    • Health Bar: HealthBar::Progress Value ← ViewModel_CombatVitals::Health Percent

    • Stamina Bar: StaminaBar::Progress Value ← ViewModel_CombatVitals::Stamina Percent

    • Magic Bar: MagicBar::Progress Value ← ViewModel_CombatVitals::Magic Percent

    View Bindings
  5. Go to the Graph tab, and implement the Construct event, setting the Player Pawn as the Combat Actor.

    Widget Graph

Create the Gameplay Widget

  1. Create a new User Widget that will be used for the main Gameplay UI.

  2. Add the Player Attributes Widget. In this example it will be anchored in the top-left corner, with a margin.

Gameplay Widget

Create the Player HUD

  1. Create a new HUD, extending the HUD class.

  2. Implement the BeginPlay event as follows.

    HUD graph
  3. Add the new HUD to your Game Mode.

Test everything

  1. Press Play and notice your progress bars are filled based on the attribute values.

  2. Modify your initial health, magic or stamina and see these changes in your UI.

Last modified: 29 December 2024