Unreal Engine 5 Data Tables with C++

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there in this video we will take a look at one of the best tools in Unreal Engine being data tables we will discover how to create new data table structures through C++ how to get data out of them and why they can help you create better games a data table can hold vast amounts of data and is an efficient way to create data driven assets for your game data tables hold related data grouped in rows where the feelds can be any valid U object struct or based data type but first let's create our first data table by defining the row structure of the table in C++ with this create a new file in your favorite IDE for this example I will create a data table holding your weapons and corresponding weapon data we create a stct with the name weapon data and inherit from table row base and Define four properties being the name damage attack speed and Rarity with our C++ struct in place we can now easily create a new data table inside unre engine using our newly defined row structure just right click and create a new data table select the weapon data row structure as a base and we are done we can now use this table to add edit and remove our weapons you can imagine if your player finds a new weapon you could easily chose this data in a nice way also adjusting the data to improve game balance becomes a breeze as you have an easy way to edit and Patch the values but wait there is more if you want to integrate actual assets like weapon models into your table you can add pointers which easily link your row to a particular aesthetic mesh or actor let's just say that we create a pointer to aesthetic mesh and we call the pointer weapon model we could use this model to attach it to a socket of our character if we equip the weapon or we can display the model in the UI is a preview just keep one thing in mind in order to have a nice performing data table you should always consider replacing object pointers with soft object pointers and class references with soft class references the reason being that when you want to access the data table for just one particular value it will load all of the referenced object and class references and therefore create huge hiccups when your data table grows so keep this in mind and just replace the pointers with the soft variants of them we have our data table but how do you actually use the data table now you can use the table like any other asset in your game let's say we have a widget where we want to display our weapon data we can create a variable holding an instance of a particular data table row and then getting all the values from there for this create a variable of type data table row handle with this row handle you can load the actual row by just calling get row and specifying the row structure we created previously in your blueprint you can then assign the row you want to use by selecting the table and the row of course your widget would need to be dynamic and not show the same weapon all the time you would need to assign the correct weapon row on construction of your widget please keep in mind that the table row handle will show you all available data tables but you actually want to only be able to select data tables that feature your created C++ structure you can restrict your row handles to only show tables that use your row structure by assigning a meta specifier which specifies the row type to be your struct then in your data table it will only show the correct data tables okay but how can we use the data tables to find rows by keys this is actually pretty simple in unre we can use the find row function to find a row with a particular key here for example I search for the role with the key long sword and it will return a handle to the data of the long sword you can also iterate through the data table with the get all rows function which will return all the rows of the data table and putting them into an array well and that's a wrap on the topic of data tables now you have got the know how to create and use them in your game I hope the video was useful to you if so please smash the like button subscribe for more game def related content and I'll catch you in the next one
Info
Channel: Scripted Adventure
Views: 2,017
Rating: undefined out of 5
Keywords: gamedev, c++, unreal engine, data tables, datatables
Id: hXZR3udztWE
Channel Id: undefined
Length: 4min 36sec (276 seconds)
Published: Sun Apr 14 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.