Skip to content

Component

Introduction

A component that is used to easily manage/track different types of actor data

Dependencies

The TrackableDataComponent relies on other components of this plugin to work:

  • Logger: Used to log useful information to help you debug any issues you might experience
  • Game Instance: Used to monitor for input device changes and handle saving/loading game data

Data

The data to track is configured by adding items to the Data map. The component should be added to the actor/character containing the data

API Reference

Properties

Property Description Type Default Value
Data The map of data to track TMap<FName, FTrackableData>

Events

Name Description Params
OnValueZero Event used to notify other classes every time the data value reaches 0 Name (FName)
The name of the data item
OnValueUpdated Event used to notify other classes every time the data value is updated Name (FName)
The name of the data item

Value (FName)
The current value of the data item

ValuePercentage (FName)
The percentage of the current value compared to the max value of the data item

Functions

Name Description Params Return
GetValue Get the amount of the data Name (FName)
The name of the data item
float
The current amount of the data item
GetValuePercentage Get the value of the data as a percentage of to the max value Name (FName)
The name of the data item
float
The value of the data as a percentage of to the max value
Add Add an amount to the data Name (FName)
The name of the data item

Amount (float)
The amount to add
float
The new amount of the data item
Remove Remove an amount from the data Name (FName)
The name of the data item

Amount (float)
The amount to remove
float
The new amount of the data item

Blueprint Usage

You can use the TrackableDataComponent using Blueprints by adding one of the following nodes:

  • Ultimate Starter Kit > Trackable Data > Get Value
  • Ultimate Starter Kit > Trackable Data > Get Value Percentage
  • Ultimate Starter Kit > Trackable Data > Add
  • Ultimate Starter Kit > Trackable Data > Remove

C++ Usage

Before you can use the plugin, you first need to enable the plugin in your Build.cs file:

PublicDependencyModuleNames.Add("USK");

The TrackableDataComponent can now be used in any of your C++ files:

#include "USK/Data/TrackableDataComponent.h"

void ATestActor::Test()
{
    // TrackableDataComponent is a pointer to the UTrackableDataComponent
    float Value = TrackableDataComponent->GetValue(Name);
    float ValuePercentage = TrackableDataComponent->GetValuePercentage(Name);
    float AddValue = TrackableDataComponent->Add(Name, Amount);
    float RemoveValue = TrackableDataComponent->Remove(Name, Amount);
}