Why use Data Tables/Assets when you can just derive from base blueprints?

I never used data assets and maybe someone else can explain some benefits of that.

Yes this is most common. Especially with widgets I write all logic in c++, declare any Slate widgets the c++ class depends on in c++, let designers create a Blueprint inheriting from it purely for design purposes. It separates the programming of pure functionality from the design process which can be good. In practice the blueprint thing could be skipped for most other things.

Often you should be asking yourself “am I making a new class, or just a variant of one?”. A variant should not be turned into a class. To create a variant you should use injection of data, which is where datatables come in handy. Datatables are a way of centralizing your data management so that changes can be made in one place and saved in a single file. Additionally they can be exported to excel so tasks like increasing the price of all your ingame RPG items by 10% could be a simple excel operation.

Using a new class instead of a datatable can be done when you need new functionality and not just data for existing functionality. You could create a bird that can fly and a dog that can run from the base class animal. It could be a different implementation of a combination of functionality as well using component classes, programming your run and flight behavior into component classes, then added to a new animal class.

using datatables you can provide or swap a large set of data to any class without the need for additional classes. It doesn’t provide functionality but data. Think of swapping out the textures for gamepad keys to keyboard keys when you swap input devices. Think of providing centralized data like how much damage every enemy in the game does on different difficulty settings.

Personally I try to stay away from blueprints and UAsset classes for as long as possible since they are more difficult to read and manage than plain text files like cpp. For widgets, animations, sounds etc you are going to let the visual or audio designer work with blueprints anyway because they need to work with the editor windows. It’s a bloated extra step because UE only works with uassets. It basically copies the source file + editor settings + writes editor data like the pins and nodes you create, instead of just referencing a source file. At least with datatables you can modify those as json or csv.

1 Like