USE Gameplay Tags

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right let's talk about these because if you are a developer using Unreal Engine and maybe you're just getting into things and you're not aware of what I'm about to explain to you I'm willing to bet that your character blueprint variable tab looks a little something like this we have a bull for uh maybe stun and another bull for uh things like if frames for being invincible and then we have another bull for is attacking and we have a a bll for maybe uh being burned if you have like a burn status and then we also have like a poison status and we have a um is healing status something like that and before you know it we actually have a lot of bull variables and that's just very messy and very annoying to have to deal with so then you might think oh but I can just make like a status effects B array instead and I'll just remember all of the indexes and which status effect effect stay corresponded they don't need to have any names and that's a little clunky as well because now you're also updating a separate document somewhere maybe in your Google drive or whatever to be able to even remember what these things mean at which point you might say oh okay but I've heard about this I've got an ID I make a string array instead and we'll turn that into a map that goes with a Boolean variable and now what we can do is we can put a name and a bully in there and this is actually the closest to being a decent ID but still that's not what we're going to be talking about today these are all decent solutions they all work but unreal has a gameplay tag system built in and you should be using it so instead of all this what we're going to do is we're going to add one single variable and that will be our tags we'll just call it uh game play tags and that will be a type gameplay tag container this is as it sounds a container for gameplay tags so what we can do here is we can addit what gameplay tags we have and by default there's no tags here but this is where we get into this because things like being stunned and having ey frames or maybe having a bull for whether or not a character is at that moment doing an attack the burnt poison healing all those kind of things you're going to need to put that on a whole bunch of different classes your enemies are probably going to need very similar things you might want to also like have a certain destructible object that you can set on fire or something like that point being is that those Bulls are going to be reused in a lot of different places in your game and there's really no sense in making all those classes all have these Co variables and then when you want to change it anywhere you need to go through like 50 different Blueprints and change them everywhere and it's just both of them so what we do instead is what we can do is we can add a new gameplay tag and we'll just name this one uh status dot stun and we can set that to be in a source we have the default gameplay tags. inii in general that's where you're going to start all your gameplay tags to begin with and we can even add a common to it so um character is stunned and then when we add that tag you will see it has a hierarchy to its tags because we called it status dot so status will be the parent tag and then dot is a CH tag stunt so now we can check and I'll show you how in a moment we can check if there's any status applied to a actor at all or we can specifically check for a status like being stunned so let's add another one uh that will be status do burn for instance and we'll say it's burning we'll add that new tag and now we'll be able to see under these status we have either burn or stun that we can enable and you can also simply uh click this plus sign over here to add a subtag which will just add the status dot for you and we can say we also want to add poison depletes health and we'll add that new tag and just like that we now have all of these tags with a parent tag so again we can check specifically for uh anybody being poisoned or burned or stunned or just check whether or not any of these are enabled because the moment we enable any of the child tags the parent tag automatically gets enabled as well and we can check that with the has tag function here so we've got the actor has tag I generally don't actually use this I generally use this uh through the bottom one here for gameplay tags and there we can put in our tag container and we can check for any specific tag so let's check for the stun tag and here we can say whether or not we need an exact match so if you want a exact match it will only return true when it is status. stun but if we say ah we don't actually need an exact match uh we just need to know whether or not it has any these status. stun so what you can do is of course you can also say uh status. stun uh for like from a hammer attack or we can say status do stunned from being stupid I don't know and at this point if we just want to check status. stunt and it doesn't matter what we do we don't want the exact match we just want to know is it's stunned at all if any of these Char tags are enabled uh that's fine that does mean that we're just stun if we do want to check for an exact match what it will do is it will check is it just status. stun no child tags applied just status. stuned so in general you probably don't actually want to have this enabled because that is the entire power of having this gameplay tag system is that you can check for a parent tag and all the chart tags will also count so just for the uh purposes of this example what I'm going to be doing is I'm going to just check on every frame whether status. stun is enabled and we're not going to be looking for an exact match because I don't really care about any of that and then we're going to be printing the result of that and let's just make a quick uh debug key F which will go into a flip-flop and that will then turn on and turn off that gameplay tag so the way we do that is with the gameplay play tag reference as well and there we can just simply add a gameplay tag and here we can say uh we want to add status. stun and you might be surprised probably not but we can also remove gameplay tags in much the same way so we're going to remove status that stuned on the B if you're not familiar with the flipflop what it does is first time you go through it goes through there and then when you go through it again it does this one and then when you go through it again it does the first one again and over and over and over again so we can see it's now printing out false when I press f it starts printing out true because I now have that gameplay tag and then when I press F again it starts printing out falls again because I don't have that gameplay tag anymore now the wonderful thing is if I make any other actor in my game so let's just say uh we make a uh test actor here and in this test actor I add another gameplay tags container these gameplay tags are stored in the default gameplay tag. ini which is just an engine file right so they are available throughout the entire project which is absolutely fantastic you can also make separate inii files for separate reasons if you want to separate the different gameplay tags from different files you can do that I honestly have never bothered with that because it doesn't seem all that relevant but especially if you're using a lot of gameplay tags maybe that can be nice to be able to separate them out anyway so now you can make these gameplay tags which are effectively just Bulls anyway just with a little bit more intelligence behind them and they are available throughout your entire project so you don't have to remake those bull values on every single object that you might want to use them on and to easily get the gameplay tag containers on other actors uh what you can easily do is you can make a blueprint interface here and we'll call that um BPI get tags something like that just in this new function we're going to add in a output that will be our tag container which will be of type gameplay tag container and if you're familiar with how blueprint interfaces work this should all uh be self-explanatory if you're not I've got a specific video explaining how blueprint interfaces work and why they're useful but now we've made a get gameplay tag container function on this interface and if we have a test actor here with our uh gameplay tags which is a gameplay tag container in the class settings we can go into the interfaces and um we implement the get tags interface that we've made and when we double click that we can get our return oute here and we simply return the gameplay tags on this and this is now callable from any other blueprints meaning that our character for instance can just try to run this function on any object it tries to interact with if it does have this interface it will get back the gameplay tag container again if you want to know more about blueprint interfaces and how to use them it works really well together with something like this go check out my video specifically on blueprint interfaces and a very big thank you to all of my patreons you can see them on screen right now if you want to help out supporting the channel there's a link Down Below in the description to the patreon page and a special thanks to to my cave dier tier patreons Sergey Thomas
Info
Channel: The Game Dev Cave
Views: 34,362
Rating: undefined out of 5
Keywords: unreal gameplay tags, gameplay tags, unreal engine, tags, unreal tags, unreal engine tags, gameplay, tutorial, unreal tutorial, the gamedevcave
Id: 1T4S2lFf19s
Channel Id: undefined
Length: 10min 38sec (638 seconds)
Published: Wed Jan 03 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.