A few questions on Data Assets

So I’m working on making an ARPG. Initially planning for singleplayer then later try my hand at multiplayer. I started building out the system to rank up attributes, skills and the like and I was originally doing it through a “Character Sheet” component that tracked all these things. Originally my plan was to use this component as part of all the enemies that would be in the game etc when my friend mentioned data assets to me and I started tinkering with them.

The basic idea I got from him was that it was a great boost for efficiency because all variables, etc could be accessed from a single point rather than be individually tracked by the instance. Sounded great to me but after tinkering with it I found that if you make any changes to a character’s stats (Leveling up, etc) it makes the changes directly onto the Data Asset which makes me think it might not be a good idea for a player character or anything needs the ability to change at run time. Maybe you guys can clear this up for me?

Can you even create new data assets dynamically? (New character etc for a new game and all.)

How would you save changes to a data asset dynamically? As I mentioned before this changes the Data Asset itself. In engine it will permanently store the changes I made at run time. It even gives me the asterisk saying there are unsaved changes. If I don’t save it I can close the engine and the asset returns to its last saved state, if I do save it then every change I made to it in testing is permanent.

Is it even a good idea to use Data Assets for anything that would have variables changing on run time? Most of the examples I see for data assets involve enemies and items. Things that will pretty much be set in stone at run time other than tracking things on the blueprint side like current health, ammo, etc. From what I’ve seen I’m leaning to this being the case.

Thank you guys in advance for taking the time to look at this. I appreciate any input. <3

This is something I have started looking into too.
First, I suggest reading and watching

https://gameprogrammingpatterns.com/type-object.htmlhttps://youtube.com/watch?v=gLWXZ3FXhO8https://www.youtube.com/watch?v=hcwo5m8E_1o

While I am still early prototyping and haven’t used Data Assets a lot yet, there’s some nice things about them. But the real question is - why use data assets, which involves creating a lot of classes, over a Data table? A Data Table is a very nice place to store a lot of data and you don’t end up with a lot of classes. But you still need to interpret the data. And adding new data properties can be a bit bothersome with Data Tables. I am not in a position where I can say whether Data Asset or Data Table is preferred.

As for your questions, changing data in a data asset will affect… that data asset. And since it’s a single instance, that affects everything that pulls data from it.
Yes, you can create new instances of data assets, something I plan to do (to allow players to design their own items) but have not yet dived into yet.
But mostly the intent is to just use Data Assets to store data.

The most interesting I’ve done with Data Assets so far is to have Item have a parent property of type Item. I can then design a base Item and make variation Items, which if their properties are null, takes the value of the parent instead. Or can Add their values. Or if there is no parent, get this Items values.

But this can be done with a data table too.

The biggest problem with Data Asset right now is that they don’t seem that stable.
First, you shouldn’t have the red data assets open while editing the blue ones (this is for Primary Data Assets), since that will regularly cause a crash.
Also, I have one variable of type Data Asset Reference that keeps being null every time I start the editor.

2 Likes

Thanks for the reply! I had watched those two videos already, Mathew Wadstein is a great source for information on Unreal. I’ve learned a lot from him and that’s actually where I got a lot of information on data assets. I did watch the WTF Is? video again though and he also advises against using data assets in any way that requires manipulation at run time. Read through the article you recommended as well and that’s definitely in line with my thinking though it’s focused on C++. I’m using BPs right now just to speed the process along though so it doesn’t really tell me about how to dynamically create and save these assets.

My understanding as to why you would use a data asset over a table is that an asset can be used as a parent class for a thing as well as be used with the asset management tools in unreal. So someone could make a shop for players then using a data asset they can easily pop up a new item, configure it how they want, and just have everything there for the next time they playtest the game. Mind you there’s the set up to be done but that’s generally what I have seen in my research.

Data assets also seem to be much more flexible in what you can do with them, easier to duplicate and adjust where a data table is a pretty fixed set of data and you have to create structures first before you can start configuring them the way you want and all that. Data Assets can have functions and everything you call from them which works out great for creating enemies and weapons.

Right now I’m using both though. Data Tables as the core, essential things that won’t need much if any changing and will be used throughout the game. For example, a skill costs X to buy for every level it has and every rank of it adds Y benefit to the player. That stuff is used in calculations and in several places so the table makes the most sense. I can just go to the tables needed and make any changes that need to happen once and it makes it across the board. Data Assets I plan to use for enemies, weapons, and items which will make everything run more efficiently as far as I can tell and it is certainly a much faster way of setting up things than the way I used to do it because of the asset manager helping me out.

What I’m still not 100% sure on is if it is a good idea to use on a player character when they need to be able to level up stats, skills, and the like because it affects the data asset itself. In the case of player characters so far it’s looking like a bad idea. Like I can just use the original character sheet component I was working on. Whenever a player starts a new game it pulls from those defaults and I can have the game save that file separate from another game where using a data asset, if I use it the wrong way or there just isn’t a way to use it the way I want to, results in the original being overridden and lost.

1 Like