How do I create objects that get values from a data table

I’m creating a Pokemon type game. I have created a data table of about 5 different creatures and all of their basic information but I am at a loss on how to use any of it in any useful way…

I created a base creature class that all my creatures will inherit from. The problem is that any creature I create only has the default values I set in the base blueprint, every single one will all have the exact same values and I can’t give them each unique values depending on what row in the data table I access.

What is the point in holding the stats of each creature if I can’t even use any of it? Do I really have to go through every single creature blueprint to create the same nodes 20+ times? Can I not just create a master creature class and create children of it which will get their default values from my data table or am I completely missing something?

Hi what is a data table in UE4?

Why would you set default values in the base blue print? You should be able to edit them. Create a custom method where you pass in values for those stats.

Create a master class that has all the methods/ variables you children classes will need. Then create a child class and edit the values :P.

This vid may be what you’re looking for (thanks to mamoniem for finding this and ofc the author for making it :slight_smile:

Basically you just need to create a Name variable in your base class. The variable will hold a name of a row that will be read by each blueprint. Then, you just use Get Data Table Row node for reading data from the data table you want. You create that logic in your base class.

After that, you have to create empty blueprint for every creature you want and define what row each of these blueprints will have to load.


Another aproach would be to expose this variable in spawn node and then spawning creatures (of your base creature class) with that node + telling which row should be loaded. If you’d also make that creature’s mesh would be defined by that variable (e.g if you put “crab” your creature will use crab’s mesh, and if you put “dog” then the dog’s mesh will be used) then you wouldn’t need to create blueprints for every creature you have. But it may be not the best solution as you might want to have some custom logic for all these creatures.

I figured I’d have to make something like that but I was hoping there would be an easier way because I’ll need to change every creature’s blueprint if I want to make a change.

Is there no way to have some parts of the child BPs appear across all children? Say something simple like a print function that I can set to be in every child BP? That would be so handy because as far as I can tell I will need to go through every creature blueprint and manually call the print function by placing the node and hooking it up. If I needed to change part of the functionality or add something new it would be hell.

Yes, you can. Here’s an example:

Parent blueprint:

Children (both got empty graphs):

Result in game: