Using Datatables to set "class" defaults for player characters

I am experimenting with Datatables for a game I am making. In the game, I will have classes with Armor, weapon, shield and other attributes available depending on the “class”.

Each Armor, weapon, shield will have an Actor BP. I am wondering if I can use the == to set the character attributes from the data table to the character? This is not how I intend to set up the character but am I on the right path? Or Should I just use a Structure without the data table?

You can set the attributes directly through the ‘Spawn Actor from Class’ node whenever you’re spawning a new weapon/shield/armor, etc.

To do so, first, create variables for these attributes (eg: Damage variable for your weapon) within your actor BP for the items. Then select these variables and set their ‘Instance Editable’ & ‘Expose on Spawn’ parameters (marked in red) to true as shown in this image:

Now if you check out the Spawn Actor node, you’ll see (if not just set the spawn class to none and back again for refreshing) these variables exposed as shown below:

Now just connect the attributes from your data table to these exposed variables and the values will be set at the time of object creation directly. No need to set it later.

What if say you are spawning something like a projectile? Would it be efficient to pull from a data table every time you pull the trigger? Is there a way to load defaults from a data table into an actor’s defaults at say compile time? Instead of at spawn time?

This should give you a good idea about the performance impacts: How to use Datatables efficiently for PUBG style item pickups.

It depends on how you access the data table. With blueprints, if you’re using row references (not row handles), it hardly makes an impact unless the number of calls is insanely high.

An alternate approach is to store the data locally in an array, but that could also eat up memory depending on the data table contents. I go for this approach if only one actor is accessing the data table info. Like for example, I have a Tower Manager class responsible for spawning and upgrading Towers. It has a local copy of the data table info stored as an array that can be easily accessed whenever required.