How to use Data Assets in UE5 - How im using them and how there awesome!!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey everyone welcome back to another video in this video I want to show you how you can set up data assets and how to use them and they're super cool and they do a bunch of super awesome stuff so before I show you how to do it I want to show you how I'm using it in the gdxr VR template so what I've got is this template has a bunch of different settings and variables and movement types that you can switch from and the idea is that the user can easily access these and go through and modify it as you wish so what I've done is and my blueprints folder I've got a data file and in here we have a actual primary data asset and a data asset itself which works together to get those variables so if I open up the primary data asset we'll create one of these in a little bit you'll see here on the left I have a variety of variables and all of these variables are what I want exposed to our player so the user can control them at runtime and between levels and set up their player how they want so you can see here we've got stuff like the main one is movement type which is an inner and what that does is it allows us to have different settings and I'll show you how I'm using these as well so if we compile and save this we can then open up our data asset and you'll see it displays all of those variables for us here as we've got them and what this does is it allows us to update the information for our player or we can reference this so in my case the main one is movement types so I'll set this back to teleport and inside of my VR Pawn or character I have a reference to our primary data asset so that's the first one with our references if I don't lose it because I close it down so that's this one so we call or create a variable called primary data asset whatever we've called it and then in here so in our VR Pawn we can select that variable and you can see we can add our data asset table and what that does is it allows us to drag this in and then we can actually get any one of those variables that we have in that data asset and update based on what's called inside of that so let's say we get Max Health we can call this and we can have this set our player so we can cause damage through this but if we went to our data asset and it actually just crashed you'll be able to see how we can actually use these through it so I just restarted the editor but the thing is the data asset itself is persistent between levels so these variables once they're set kind of act like a game instance so you can change them and update them here and it'll store it between the levels and the main issue that I found is data assets themselves can't be saved but the individual variables can be and then you can set them when you load your project so hopefully you're seeing how these can be pretty powerful and can be used between different actors and levels and you can duplicate these as well to create different types so you can have uh let's say you've got an AI character there's a whole bunch of variables that you want to set in there you could have a data asset for ai1 data asset for ai2 and you can have them set to different things so they're reusable as well which makes them super powerful so how to create these so what we're going to do is we're going to close down this template that I'm working in and we're going to open up the Epic Launcher and what I'm going to do is I'm going to set up a first person template so this setup is exactly the same no matter what template you use it's just a logic that you've got to change or the way you you where you use it in your project is just going to be different but the overall concept is exactly the same so I'm going to use this so I don't have to put on the headset all the time so now that we actually have our project started we can run in here we can jump around we can fire still and what we're going to do is we're going to set up our data asset to control some stat in our player so what I'm thinking is we can do a new folder all this data and what we're going to do is we're going to set up a Boolean value to stop our player from being able to jump so we can right click and what you want to do is go to blueprint class search for primary data asset and this will be used as a similar thing to a game instance it's going to store our variables of what we want to be able to access so primary data asset pde for short and then we'll call this character variables and then in here we can open this up and let's say we create a new variable we'll keep this as a Boolean and we'll go can't jump cool so we've got hand jump as a variable it's a bull by default we want that set to true and now what we can do is we can right click and we can go to miscellaneous and we can create a data asset and in here you'll have a bunch of classes you can choose from and what we want is our PDA character variables so we select this so data asset underscore character variables and if we open this up you'll see that we have our can jump variable displayed to us which we can turn on and off so we'll keep that on and in our first person we want our blueprint for our player and it's going to be our BP first person character and what we're going to do is we're going to look for our jump section so we have it right here and let's say we want to disable our jump what we can do is we can start with a branch and we need to access our data assets so we can do that on the left we can go to variables create a new one and the data asset variable you might be tempted to search for data assets so searching for data asset underscore character but that won't actually show up but you'll see that we get the the primary data asset itself so we've got primary data asset character variables we want to do an object reference we'll rename this to character variables and on the right here once we compile we'll be able to access our data asset itself so this one's reading the information from our data asset and we can use that so if we drag this in get and then we do hand jump so get can jump we can plug this into our VR form the compile and save so now if we jump in we pick up our weapon we can still jump but if I go to our data folder and open up our data asset and I disable this when we jump in I can press the spacebar as much as I want and nothing's going to happen so how can we use this so can't jump we can turn that back on hey everyone update from the future so while editing the video I realized I didn't mention this is that when working with data assets if you want to modify them at runtime and you set their information as you'll see later on in the video that information is stored between the editor versions as well so if you escape up your project any any variables that you've changed in your data asset while playing the game will stay as they are in the data asset it doesn't save directly between games so you will need to create a save system if you are changing anything in the data asset but ideally you should really be using the data asset for stuff like settings that are only going to be changed once or twice a thing you're not going to want like I've got in my example I've got Health it's not going to be in there it's going to be moved to the game instance where it's going to be stored or a player controller so you kind of want to keep that in mind so the best way to use the game the data asset itself is to only have variables in there that controls the default State and work from that that works much better rather than updating stuff but um things like menus and stuff like that you can use this if you want as well and then you could export so you could bring in your data asset into your game instance or at least in theory you can I haven't tried it yet and then save out individual variables so when you load a save game you can populate the data asset with those saved variables so that would be one way of saving it but um overall the data asset and the the primary data asset doesn't save as a whole as a whole file so just keep that in mind while I go through the next steps and show you how you can edit those variables on the fly all right back to the video we could go ahead and we could create a blueprint class let's call this an actor so BP underscore uh disable jump after and then we have a collision box Collision we'll move that up and then we'll put a little Cube on the bottom just so we can see what's happening and more accurately see where we are and we'll do that like so so our box we're going to use on overlap so I'm beginning over that we're going to check to see if our adapter is equal to our uh first person character if it is we're going to disable our jump typically you could get our player Pawn so we could cast to our first person character and then search for jump and you could do stop jumping or can jump and you could set that as you want but we can do this without casting now so in our variables list we're going to search for our PDA so character variable primary data asset rename to character info hit compile and then the drop down to the right we search character variable so we get a reference to this and now we set and jump so if I play overlaps our Collision box we set can jump to false so if we drag this into our level now we can get our weapon and we can jump as we normally do and then once I overlap that it did not work so let's see if we're actually overlapping it properly don't think we are some of them oh we are so I double checked it's not actually receiving the first person character so there's no Collision on that it's been a while since I used the first person one so let's do it so when we overlap without the check so we jump in we can jump like normal and then once we overlap I can no longer jump so I can press the start and then go from there and the best part about this is if we load a new level it'll Steve that data asset as well so it will have jumped disabled so you could do another one and then have this from multiple variable set this to public so we've got one jump pad down here which has can jump set false and let's say we have another one up here which is set to can jump to true and in our first person player just so we know we're actually hitting our space bar we will do it so we checked let's call it jump disabled and then jump first person cool so once we press it you can see that we've got jump and it's actually disabled because it's persistent so we disable it and it's set it in our data asset so now if I want to enable it we can go over here we can jump and if we back out our data asset will be set to true but if we go back in and then we can jump again as soon as we overlap this I can no longer jump so jump disabled and when I back I'm going to data assets you can see it's saved it so it stores that information in the editor and in the level in between them so there's a lot of power that you can get out of this and you can work with it how you want and it also saves it between levels so if you like I've said if you load up a new level with something modified and disabled it'll actually keep it for you so it's a super cool way of doing stuff and having that logic go between the player without having the so-called cast or do anything along their lines especially if you're doing General checks it works really well so jump disabled can't jump but as soon as I hop over that we can now jump again and then go over it and the same thing so jump disabled so this was hopefully I didn't ramble too much I think the idea is to just show you how dataratus can be used to not so much cast but do checks and general stuff and information and also store in that info and one thing I believe isn't possible is to save this data or specifically save the data asset or the primary data asset between games in a safe game but what you could do is you could access this character variable inside of a game instance and you could save that variable and then when the level loads you could set it back to the character variable or the data asset to have it go that way so this is one way of using it and hopefully that helps you kind of come up with some new stuff things you can go from there so you can have player assets so if I jump back over to our VR template and open up the data asset in here you'll see how that I'm actually able to use this so max walk speed I can control that here Sprint speed and I'm also looking at doing stuff like Max health so things that won't change and the player will always have accessible to them the max Health could be changed here so if you get an upgrade it could change it to 200 and then your current health would stay the same and it can be read inside of your umg as well so all these variables can be accessed everywhere the only thing they don't do is call the change it's just when something else looks for it so that's the thing to keep in mind something's looking for that data it can access it but if you're let's say you're going to take damage you wouldn't have it go to your data asset and expect your umg or anything like that to read this data on the Fly it's pretty much done as a background thing so hopefully that really is enough rambling now and that helps you get started and it's just something cool that you can think about I want to say thank you to on patreons for making these videos possible especially with the help on the gtxa VR template which we're working on here these are the videos on the channel if you want to see what this is but if you're looking for any help make sure to join the Discord and we'll be over there regularly so we can help you out so yeah until next time stay safe and I'll see you then bye
Info
Channel: GDXR
Views: 15,656
Rating: undefined out of 5
Keywords: Gamedev, Indie, Indie Gamedev, Indie game Devlog, Game Devlog, Game, Dev, XR, GameDevXR, Blueprints, Coding, Unreal, Engine, VirtualReality, VR, ExtendedReality, tutorial, how to, how, To, develop games, making a game, Dev Log, beginer, Unreal Engine 4, archviz, architecture tutorial, beginner tutorial, basics, blueprint tutorial, blender, beginner tutorial series, coding, devlog, Jonathan, Bardwell, code, unreal engine 5, UEVR, bardwell, log, development
Id: ORye2_bkz3M
Channel Id: undefined
Length: 17min 1sec (1021 seconds)
Published: Thu Dec 01 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.