Skip to main content

Load Default Values

Call LoadDefaultValues()

Calling LoadDefaultValues() on the StatsComponent will make it pull data from the Default Values.

note

In a multiplayer environment, On BeginPlay, use HasAuthority() to prevent LoadDefaultValues() from being called twice (Server and Client).

Default Values Name

To find its RowName in the Default Values Composite Table of the Default Values Manager, the StatsComponent will use the Default Values Name specified in the LoadDefaultValues() function.

Using the Owner for the Row Name

You can make the Default Values Name dependent on the Owner Actor by creating a function and returning an ID from the Owner.

Example

I create a property "CharacterID" inside of my main Character class.

Setting it to "Instance Editable" and "Expose on Spawn" will allow me to fill this property when spawning it.

Now, I can create a function GetOwnerDefaultValuesName() in my StatsComponent and return CharacterID by casting to my Character class.

I can now use this function to load the Default Values in my StatsComponent.

note

When my Character is spawned, its StatsComponent will call LoadDefaultValues() on BeginPlay and search for the Row returned by GetDefaultValuesNameFromOwner() ("CharacterID") inside of the Default Values Composite Table of my Default Values Manager.

Accessing the current Default Values Name

You can get the current Default Values Name of your StatsComponent with CurrentDefaultValuesName.

Using a custom structure

You can also load the default values using LoadDefaultValues_FromStructure_().
This allows you to create your own structure and use any SDV structure inside it.
You can read more about that here.