Reading: 

Plugin: Status Effects

Next:  About this plugin
Introduction

The Status Effect Plugin is used to track and modify "Status Effect" values over time. In games examples of such values are: health points, player score, a hunger meter, a happiness meter. Create any effect.

This is especially useful in games and simulations where so many different effects can be created.

Modifiers can alter a Status Effect over time. For example, to remove stamina while running, or add health over time.

The Status Effects plugin is very compact and set up to make it simple to implement any effects and modifiers, through code and datatable.

The UI can be connected to display information of a Status Effect.

The example given on the image is a demo project, which is not included with the plugin.

Benefits
  • Track and modify values over time.
  • Compact and universal. Ideal for games and simulations.
  • Simple to set up in code and datatable.
  • Widgets can connect to Status Effects (add a health bar to your game).
  • Multiple modifiers can alter a Status Effect over time.
Requirements

You can get this plugin here:

  • Status Effects

This plugin does not depend on other plugins.

Installation

First follow the docs on how to install a plugin in general.

This plugin does not require any setup.

While not made a requirement, I strongly recommend using my plugins "Central UI", "UI Additions", for implementation of any UI.

Next:  Usage
Status Effect

A Status Effect is a class which manages a single value (float). It tracks the current value, it's min / max amounts and broadcasts events for when the value changes, or when the value reaches its min / max amount. Status Effects are injected into a Status Effect Component. There they are named and track a value with a purpose, such as a character's health or stamina points. The Status Effect itself is injectable for any purpose, which is especially useful for games and simulations where many different effects can be created.

Status Effect Component

The Status Effect Component is a manager for status efffects and their modifiers. This component can be added to any actor. In games this component is commonly added to a Pawn, to track status effects related to that pawn (health / stamina points etc.).

Blueprint users have access to various methods and events, to manage status effects and modifiers.

Effects and modifiers can be inserted or removed through code at any time, as shown on the image. On the example the effect "Health" is inserted, which is modified by "HealthRecovery", increasing "Health" 5 points per second infinitely. Modification happens on every tick.

In code I recommend storing the names of the effects and modifiers as constants, so that there is no risk of typing mistakes. You could also use a datatable to load the data from. Datatables are easy to manage as text / csv, and produce reusable data.

This example shows the configuration of a datatable containing effects and modifiers. I added "Health", "Stamina", and their modifiers.

A Status Effect modifier will be removed automatically when its remaining duration reaches 0. Think of a fantasy game where you drink a magic potion to recover some health points for a few seconds.

Status Effect Info Widget

The "Status Effect Info Widget" visualizes data from a status effect. The example uses a bar style to display health / stamina points for a game character.

Widget designers have full freedom over their design. A bar widget is not required. Designers override the method "Update Status Effect Appearance" to implement a visual response to changes in values of the status effect.

A Status Effect needs to be tracked. This is done by calling the method "Bind Status Effect" on this widget. Status effects are retrieved from a "Status Effects Component". This component is usually added to a Pawn, or another actor.

Visibility of this widget is automatically managed. This widget will collapse when the status effect is removed from the Status Effect Component, and shown when inserted. If you want additional control over visibility of Status Effect Info widgets you should control visibility of a parent panel.

Blueprint users will find several methods on this widget to bind / unbind the widget to a status effect, or retrieve information about the current binding (if any). The retrieved Status Effect contains more blueprint accessible methods to get information about its current values.

Status Effect Panel

The Status Effect Panel is a User Widget. It is an example asset which shows how to set up the "Status Effect Info Widget" on a panel, setting up their style and status effect binding in one place.

In the example I retrieved a Status Effect Component from a Pawn associated with the widget's controller. The Pawn was a logical place to attach the component, because this component tracks the Pawn's health and stamina Status Effects.

The "Bar style" property shown on the image is added just to the example Status Effect Info Widget, to set up a different color for different status effects. You can implement the design of the widgets in any way desired.

The simplest method to get the widget to show on your screen, is to add it to the viewport as shown on the image. If you are using my UI Additions plugin and follow best practices, you can follow its documentation to add this panel to the HUD in a different way. Its HUD class properly manages the entire UI.