I created Data Assets for each items like weapons, collectables etc. And in the Data Assets i keep the informations that name, meshes, gameplay tag, descriptions. I want to create instance for each item and define price each one of them. Then I want to change price at runtime on game instance. How can i do that? I’ve tried to create game instance but can’t get data from Data Asset. What should i do?
Data assets are [usually] used for the definitions of the items, not the reference of the item in the world. Your actual physical items in the world (or on the player, or in a save game) should usually be stored in a raw data system, with as few variables as possible, and stored as an “item slot.” The item slot then specifies that it uses that data asset as it’s “item type”, and whatever other dynamic variables needed (quantity, etc.)
I’m not sure what your plan is for pricing, but does it have to be per item? Usually a global price modifier works best.
The data asset would store a “base price” which never changes, and then everything bought/sold on a vendor would use a multiplier. I.e. if your character has a discount at the vendor, everything might be multiplied by 0.9 (10% discount.)
Individual prices would work fine if you want to store it in the item slot as well. Generally an item slot is just a struct (in an array), or something simple as possible.
First of all, thank you for your answer. I’m trying to develop a store management game. I plan to buy items from other vendors and sell them in your own shop. And you can change the “sell price” in your inventory and put them on the shelves so AI NPCs can come, take and buy with your price (not the base price). Because of that, it has to be per item.
I create a Primary Data Asset, and it has variables like name, type, description, static meshes, and thumbnail images. So when I add a new item, I create a new Data Asset and choose the parent class this PrimaryDataAsset. I chose the mesh from the content folder and filled in the other parts, and it looks like DA_Weapon1, DA_Weapon2, etc.
I’m a little bit confused right now, what should ı do? A lot off topics says i should go with instances, but i Don’t know how to do it.
ill recommend using a data table instead of data assets.
they are somewhat interchangeable, but a data table can be modified and saved at runtime.
as well as are able to be imported and exported to csv and json.
the other benefit of a data table is that you’ll end up creating a struct, like wrex suggested.
and you can create variables for that struct as many times as you want, so you can keep track of runtime instances even without using the data table. for temporary values for example.
if your items prices are going to change wildly, as there are 5 items that are technically the same, but then you buy and sell them for different prices at different places. then you might have better luck with a custom subsystem that can store and persists these combinations. though something like an inventory could do.
primary data assets server other purposes iirc. don’t confuse them with data assets.
i think you should ideally break down the mechanic in several pieces and separate them, that way you can understand it better. as of now it sounds like you’re mixing several steps together and causes you confusion.
good luck.
benui gives a bit of unfair bad rap at data tables (and ue), but data tables are pretty amazing.
for an example here’s my free and open source inventory plugin, it uses data tables.
and this is the struct i use for items
as you can see it has a few variables at the bottom marked as “transient”. i change those at runtime. i keep instances of that per acquired item.
You are the one and only! Thank you a lot
forgot to say, json and csv are really important since you can edit them in spreadsheets which is super helpful for designers.
i even made code to load those csvs at runtime, so you can allow mods of your game if you want. or change after packaging.
my pleasure <3 thanks! it made my day ![]()
I think maybe the main problem is you’re not fully understanding data assets and how to use them. They are excellent for item definitions. I personally believe data tables are 99% obsolete if you’re starting a project in 2025.
All of your current price data should be stored in the inventory struct entry for that item that you are holding (or tracking), which is locally connected to either your player, or something in memory. You would never want to store dynamic game data in the data asset (nor a data table!) Storing any dynamic data in a data table/asset is just wrong IMHO.
In development, you can do anything and your final produce will “work”, but I still think there’s a good and bad way to do stuff in video games.
I realize you marked a solution, but I strongly recommend against that.
i disagree. but it’s ok, i respect your opinion. it’s a preference and it’s ok to use whatever you feel more comfortable. data tables have their place, maybe not for your projects.
yes but there’s not only one way of doing things. and there isn’t only one good way and the rest are bad. that’s over generalization. it’s a pretty common pitfall in programming, it’s a bias.
otherwise it becomes dogmatism. every thing has pros and cons, and you have to weight those and choose the best for your project and situation.
i agree he probably doesn’t understand data assets properly, and i think it’s fine that you put your recommendation. i would still let him try them out so he can choose. it’s his project and his choice. and he needs to learn when and why each solution is the best for the task, and that requires practice.
You literally chopped off the first half of my quote there, that already said that. There’s always more than 1 way to do something. I think using data tables to STORE dynamic data is an extremely poor way to deal with data in memory.
The poster came into this thread, using data assets (which was good) and was steered towards using older (and more limited) structures instead.