Unreal Engine #03 - Gameplay Ability System (Deep Dive into the basics)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
there we go i'm live so let's get start to it let me just minimize it and close it up all right so welcome everyone um the last video like last couple videos i've updated about tdd and automated testing in general for ue4 and since then i've been studying the gameplay ability system instead of you know building my own whole system i figured out it might be simpler and easier to use whatever the engine already have available for us so um so let's go back to the already again as again as again as as in the past basically you have to prepare you have to prepare your whole environment set up so you have to add a couple dependencies on on your on your project settings so basically i've modified the build cs file so basically i've added a couple more dependencies over here so this is the dependency needed for the gameplay a billet assistant so before we even start what is the gameplay update of the system basically is um a built-in system inside of your engine that allows you to program cotton plaques um gameplay systems without you know needing to create all all the variables and everything like create all the the logic yourself you can already rely on the system to build like uh let's suppose you're building like an rpg system you need like skills like you need like skill tree you need like i don't know uh to cast a spell or to use some potions you know the default gaming play system that every game at least most of the games already you know have so you can use that to program in a simpler way that those interactions with your game uh instead of you know building for the ground uh though it's right now as far as understood c plus plus only at least the basic config is c plus plus only so that's uh and since i use c plus plus it's just fine so but you can do as well a lot of things and blueprints once you expose that to blueprints but first of all you need to open like your project and add that those dependencies over it over your build file so it's the gameplay ability the gameplay tags and gameplay tasks so these other uh dependencies you can see the first video i did to explain why i've added those uh also you need the automatic test dependencies because we're gonna have some unit tests for or our you know our components and our and our code itself um also after doing that you can compile it and it should be just fine but uh on your character itself let me just go back to the character uh of course you can have to you know create everything like the component the classes and everything but uh uh you have to add these libraries like these headers as well like the gas attributes and let me see there we go the ability system interface so you need to add that into your header file of your character and also uh extend your character to not be only from public but also add this interface to it otherwise you're not going to be able to basically do anything uh regarding the ability system component so it's something that needs to be done on cpus plus as well so that's why you need like a c plus c plus plus project c plus c plus plus character and things of sort um besides that you're gonna need to basically the gameplay ability assistant is composed by the component itself which is this gameplay updated component it's not of this type but i'll show you how to create one is basically you just go to the c plus classes you can organize your folders the way you wanted to i separate into components i created like a folder game playability system and then i create the component over here and the class itself if you need to create like a new class you can show all classes and search for game play ability component oops gameplay ability where is it i think that's the component right i think that's the name of it let me just check gameplay ability assistant sorry so it's gameplay ability system where is it why it's not showing here anymore is it the whole thing on well basically you need to create this class which is from the gameplay ability system you know its inheritor from the gameplay ability system so if i open up like this you can see that is inherit from visibility system component so i should be able to find that out i'm not sure why i'm not i'm not finding it but uh oh there we go it's there so okay so you need to create your bullet assistant component which is the gameplay ability this is the component itself uh but the component itself it's not going to do anything if you don't have the attributes so you need to the component itself is going to manage which ability each character your character should have when you should um you know activate an ability or deactivate it if you should commit uh the ability commit which basically is decrees some uh you know for example commit would be apply the effect of the cost actually sorry not the effect apply the cost of that uh ability so the commit would be like let's suppose you spell like you cast a spell and that spell cost 10 of mana or something like that uh to actually apply that cost to your character you need to commit before but yeah basically the whole ability system is managed by the component itself so they create like a a one called gas component so that's my class also i need the attributes itself which is basically the character attributes so in the last video i did basically um a health component so you wouldn't need like a health component because that's like a you know status like an attribute that i could store inside of my gameplay ability system instead of you know storing like a local variable or something of the sort i could store every single character attributes inside of those uh that attribute class and that attribute class it's from the attribute set class so if you search it up for that once creating your a new class you should see like this attribute set uh this is an example like of attributes but basically you know those are uh the main at least the main things that you need to create to start uh interact with the the ability assistant component so basically inside of your character you're gonna add the interface to it and let me just delete this new line because i don't need it but uh and once you add the interface to it you can just declare your component like your game playability component you can name it whatever you wanna name gas component uh when i create the c plus class and you need to create the attributes itself which is you know all the character attributes stored at one single place so the health mana stamina strength and everything of the sort uh yeah so now going back to those you know wrote like the bare bones of the game playability system on the attributes once i created that i need also to include the ability assistant component otherwise if i need to interact with it i may not be able to you know do anything with it but i think that's my that might be already included by default but if it isn't just include that also this is a macro that is inside of the u attribute set so instead because if you see the epic games uh video of you know there's like a three hour video explaining it like the bare bones of it which is really great i highly recommend it for you guys to see it but uh if you see that video you see that he kind of set for each one of the attributes that we're going to specify for the character he creates like three different lines like three or four macros in order to you know as configure the getters and the setters for those attributes uh instead of doing so i highly recommend it to you to just open up the eu attribute set and some somewhere in between here you're going to see that there's an example like of the macro i think it's there we go so there's an example of the macro instead of you adding all of that boilerplate code like four lines you can add like just one single line by defining this macro and you know it should be simpler than you know adding four lines as they do on that video so basically i copied over that macro over here so it's just a matter of copying over no needs like a boilerplate code there's no need to alter anything on here and all my class itself i just created the constructor and i'll go into those functions in a bit but then i kind of declare the com you know the attributes itself but also i've left not attributes but and that's like a personal choice of mine it doesn't need to be yours but uh i've created like float variables as well inside of it so i can add it later into the engine like what should be my max health what should be my max values of each attributes that i have it if you set it up like edit anywhere an nav gameplay attribute data which is basically the the kind of variable you're gonna use for each attribute of your character you're not gonna be able to you know manually add it like through the editor unless you do some some blueprint uh coding or setting on the constructor or whatever so i found that it's a bit easier to manipulate the maximum amount of data just by typing into the editor like any level design could just open the default class settings of the character and he would see like what should be the max amount of health for the enemy or for that enemy or for that character specific so those i just set it up like is a max health max strength and max for each one of the attributes that i'm going to show you how to specify in a moment uh so those are just for variables you shouldn't you know shouldn't should be equal like any other sort of uh coding that you might be already used to but uh the properties itself from the gameplay ability system is this game f gameplay attribute data so that's the type of variable i know it doesn't sound like really user friendly but really what it simply is is like you set it up like a flow value like or you know like set it up like a value for that attribute into your character and that's it basically it's simple as simple as that and then we use that macro that we created at the top of it to kind of set it up all the setters and getters for our attribute so we don't need to if you see again if you see the epic games of it you're gonna see that he writes i think four lines for each one of the attributes i think it's just too much boilerplate code uh to to see and you know to manage and i found that it's a bit easier to just define that attribute assessor that is gonna do basically that those four lines uh but while rating it's easier to just set up like the assessors with a single line so you set it up and again if you set it up like multiplayer like uh replication you're gonna need to set it up uh a couple uh different steps like the app notify or something like that or you need to specify like the do wrap uh i forgot the name of the the function that replicates the wrap lifetime something that does replications of your variables based on a condition if you wanted to but uh i i do have like another video that i might have and i may leave it once i finish it up this streaming i i think is rube something the name of the guy and he explains on how to set it up for application for attributes as well uh but since this game is not gonna be any multiplayer it's just like you test like a devlog test for uh you know local like one single player game doesn't need any replication for it uh and again i set up the health attribute i set it up to strength uh the stamina uh the mana or magic points whatever and the speed as well uh and based on that i already have again since i already built this i do have also my tests let me just open up the private folder the test and they do have like a couple you know tests for the for the gameplay bullet assistant and those tests them just you know try to oh there isn't like it really easy oh there we go i knew it was easier than that so i do have like a couple tasks that i already specify foreign and those tasks are basically like i need to have like a set a set of default again as i did before in the previous video for the ddd i write my task first and then i read my code later and in order to make my tasks work but basically i do have to have like a default amount of for each one of those attributes one volume is spawning my player i do have a test also for whenever i change an attribute or my attribute should never be negative you know and all those sort of tests that you know if you want to see how to test your code like how to unit test or how to end to end test follow up the previous video that i i just presented i just wanted to mention that there is tests for each one of each one of the functions that i'm going to present to you sorry let it go let it go and let's continue so basically i set it up the uh the default attributes but i haven't set it up what should be the initial value again you could set it up this for from data tables you can set it up this from a base uh default gameplay effect which i'm gonna explain what it is uh in a couple minutes but uh you could also specify into the constructor of your attributes what should be the default value for each one of the attributes that you you know created and once you specify that and you set it up that attribute as you you know into your character those variables are gonna be exposed to the game playability assist gameplay component and whenever you you know want to set the attributes or whatever you're going to set these variables like these attributes uh so if your character has more variables just you know specify more of those gameplay ability gameplay attributes data variables uh and that's pretty much it also i do have like a couple other functions and again oops there's a typo in here so there we go so this pre-gameplay effect execute it's a function from the game the attribute set class that basically allows you to before you change any attribute internal data so before you you change like for example you cast a spell you need to change uh the magic points of that character or you need to decrease that or increase whatever before you actually do that that function is going to be called and you can basically manipulate as you want it to so if you want to do something before changing like make some sort of validation before it well that's the place to do it also this post like it's the opposite of the pre gameplay effect execute dispose glimply effect execute that actually what's going to be done after we change that attribute itself so before changing do some validation and after changing you could also do some sort of validations or maybe uh let's suppose you have some sort of punch ability or something of the sword that we're gonna actually use it on the pulsed effect you can actually check how many how much stamina your character has and based on that making him make him slower or something of the sort so that's how you would handle uh you know effects on your character before or after or do some sort of validation before after changing any of the any of those attributes itself but again that's only regarding the afghan play attribute data not the floats that i specify as a maximum value i just use that for maximum reference for both uh or anything of the sort or even tests so that's basically it and again i just do nothing i just call it super because right now i'm not doing anything on the before changing attribute but after changing the attributes and again i do have tests for that i do check if i'm change to check which attribute you get you're actually changing it you actually just do that grab that data uh gameplay effect mod called mod callback data variable and you can evaluate the data grab the attribute and check if your attribute is actually this get your you know your health attribute and remember this function never specified but that's actually the uh purpose of that uh handy-dandy handy-dandy macro over here so that specified getters and setters for us so basically what it does is you know allow me to just call it get health whatever it's gonna it's gonna present me if something like let me just present together help get health attribute or get help they help value or get health attributes gonna have like gonna grab a reference for the attribute itself to check if it's you know if that is the attribute i'm changing uh but if i want to get just the value of that attribute i would just use that get health and if i want to set the value of that health i'm going to call it set health so that's basically what that [Music] macro is doing for the attributes itself also there is the initializer so it's initializing as well but uh i never use that macro at least not any not not at least so far so yeah so basically that's how you would check which attributes are actually manipulating because remember this is going to be called for each every single attribute you manipulate during your game so if you have over like over four or five attributes in mind you don't want it to change like to do some effect on based on let's suppose you decrease the stamina you don't want to you know cause an effect on the mana or the magic point or on the health the character you just want to make him slower so you want to be sure that you're just testing and manipulating the stamina uh so that's how we we check that so if i'm changing the health attribute then i'm just be sure that i'm not uh i'm clamping the value to be sure that it's never negative as i did before on the previous video and then i'm setting if the player is alive or if it's dead that's basically it uh if the attribute is just the strength i'm just you know setting the strength and be sure that all my values are never negative and i do that for all the all the other attributes as well but basically this the stamina attribute if not only i set that as you know to never be negative but i also double check if his tired so i do have like a requirement of if the stamina is below 10 which is one value uh basically i'm gonna make him slower until he recovers his stamina to the point of it's above 10 percent of stamina so i do that basically over here so that's how you would use like this post or pre-gameplay effect execute functions inside of each one of your attributes so i know it sounds a bit complicated right now but uh it's just a structure so inside of your attributes you control uh each character attribute and how it's going to behave if that actually changes if you want to validate something you get you're probably going to need to check here uh and the component itself it's the uh the one that actu actually is going to call the ability and manage this communications like an interface that is going to manipulate your attributes or you know set you know basically manipulate manage the whole attribute system okay so that's about attributes and that's of okay the ability component itself let me just go back to the let me see if i can find the constructor so i can oh i need to open up the character so there we go um not only you need to specify that variable you need to you know create the sub default object in order like like anything you kind of declare on the construct like as a variable for a character so not only that i need to let me just go back to the there we go where is it oh there we go so the gameplay ability component i create a sub default object of the class i created which is a u-gas component as i named it but remember is from that game playability component system uh i named it as a game playability component and the same i should do for the attributes and that should be about it those are just default verb i kind of have like a boolean to double check whether i do have the gameplay ability like the gas active or not uh so i can do some something but if it's deactivated i don't wanna you know manipulate or uh do anything with it so i always double check if the actual gameplay ability system is actually active or not um and yeah that's pretty much what i have for this and but yeah not only that uh the gameplay ability component as i mentioned is the it's gonna be the one that um it's gonna do basically you know manage your skills or anything of the sort so if you open up like this on let me just go open up the let me just grab the variable itself let me just find it on my code oh yeah there we go so whenever i'm setting up the import player component oh sure i forgot to mention that as well sorry but uh you're gonna have you're gonna need to have for example for each one of your skills you're going to have to set it up like a key or something of the sort to actually cast a spell or cast that um uh ability so instead of my festival like my main header file i've created already these enum like called gas ability input id so if you see the epic games the the guy actually uses like integers as how to check which like if the which ability is being activated or you know to control it i found that bit troublesome to do i i rather to actually have keys associated with it so what i did basically is i created this none confirmed cancel which is basically default but i do create my own input as well named punch so if i want to create like a different one like suppose your ability it's going to be named i don't know heal healing or potion or whatever you just name as as you wish here and once you do that later on on the ability system you expose that variable to set it up which is going to be the key uh responsible to activate that ability so just to be uh really simple let me show an ability really quickly to you guys so let me just open up playable skills abilities melee attack ga which is the gameplay uploaded so if you go back there's this is ability input id and i set it up as a punch again there's none confirm cancel later on i'm going to expose that variable to an actual ability uh so that's why you're going to see you're going to need to create that enum inside of your festival you don't need to if you want to you know manage your skills as the guy on epic did using integers but i found that this is a bit useful a bit more useful than uh specify specific integers for it and also it's easier because what that bunch x is going to be is going to be the same key you set it up on your project settings let me just find the input there we go input so you're going to see that actual mappings i do have uh if you set it up like a variable here with the name punch or you can you need to specify with the same name inside of your input and basically it's going to match whatever key you set it up here so if you set it up the left mouse button the punch is going to be it's going to try to match what inputs you have and if it finds like one that sex like the exact match match for your input it's going to use that as the input for the ability so i found that a bit more useful than using like controlling by integers i know it's simpler by integers but i i found that you know for me it's a bit more useful you doing that because it's easier for me to control uh what input i'm gonna actually use for for my abilities than you know calling by integers so basically um whenever you set it up your player input component and that's the default um thing that comes with epic whenever you create like a character variable or character class you're going to see that it kind of binds uh these jump action to a specific key event or whatever like press release and it's gonna call like a specific function so on the other hand you want to once you know creating like your input components as well uh also specify the activate like the activation of your your abilities to the uh to the i can explain that you want to specify and also set up the inputs for your abilities based on whatever you set it up here and whatever you set it up into your ability at the end of it so basically what i did here is i double checked to be sure that i do have actually like an input component and also the game playability component which is my you know gas component and if that's true which means i already have those created then i'm cut like i'm casting to this gameplay ability input binds i'm grabbing like what should be the confirm on that enum what should be my cancel command on that enum because your ability system you can confirm that you cast it you can cancel a cast in the middle of the cast so you can maybe maybe you don't want to cast an ability if you're taking damage you can cancel casting you can manage that through the abilities of the component and the enum name which is basically the name of the variable that i created here which is egas ability input id so each needs to match exactly over here and the target input uh which is basically the confirmation that you know the ability has been cast it's going to be the confirm so you can see that here and the cancel is going to be the cancel so this is basically creating a bind to be sure that when i finish my my casting when i when i cancel what should be the enum that i should consider uh to use to bind my activation or my input component to my ability uh gameplay ability component so i set it up by confirm cancel and this is allowing me to use that custom enum as my and binding that to my activation to input component uh i don't do that only here if i'm not mistaken [Music] let me just double check here oh let me just double check here no yeah yeah that's that's really real word tutorial sorry uh if you want to do that on the multiplayer side of it you want to do that i think in the post uh possess as well because i think you want to only bind the activation through server or something of the sort but yeah i'll leave the video below as well he used that approach and i found that's a bit more useful than just you know by the integers to it so based on that is grabbing the confirm in the cancel which is basically here and whatever i add below here it's gonna be uh my custom inputs so if i type punch if i type i don't know uh potion or whatever if i set it up a new input name potion here and set it up like what should be the key to activate my potion it's gonna match exactly for me uh if that's not useful for you you might be more suitable to just using integers as the guy on the epic games tutorial that but uh yeah uh okay so i set it up my my input so i bind my inputs to my game playability component so which input should activate watch what should be activate my gameplay ability component what should be the input components that i'm going to use for uh and later on on the begin play again if i do have both my attributes and my gameplay ability i do initialize my gameplay ability actor info and it asks for an owner and the avatar of that is controlling that um gameplay ability component on this case since my actor is actually the one that i'm gonna be that's gonna be the owner and the avatar for it i just specified this and this and that should be fine and then i set that variable as a true uh and again i set the player speed by grabbing the speed from the attributes and there we go okay also here on the get stamina okay i set it up the basic stamina also i check if i do have like a variable name melee ability and that's basically my default ability which is basically punch ability uh so if you have like default abilities of a character like maybe millick melee combat or i don't know fireball if you're a magician or like if you're a mage or something of the sort uh yeah just like or arrow like bow and error or something of the sort uh you might need to specify those default abilities as well on the beginplay if you wanted to uh and by given the ability which is basically my milliability which is a variable here let me just find out that variable really quickly to you there we go ugass gameplay ability uh i set it up that on my character and then basically that gives the ability to my um the punch ability to my my character okay later on as well on the apply damage function i do need to check as well but again i'll go back to this in a moment like what should be what what are effects what are the abilities itself i set it up a couple getters and the giveability as well i was playing like a in a little moment once once we have the the whole point of what should be ability what you know what are our abilities what our effects and yeah so basically right now we have already the attributes covered and the gameplay ability uh component covered like how to set up that bare bones of it but uh now that you have your ability component system and your attributes already set now things are starting to get a little bit more interesting because you can actually specify the abilities just by having those two uh and when i meant that it's because you can apply effects without having abilities and you can you know spawn cues without you know that you can use that to manage uh c plus plus effects directly without even you know having to create those uh but yeah what are effects what are gameplay playability system besides the attributes and the whole component itself is basically like in the bare bones you know built on based on abilities which are actually the abilities like you can imagine like a tree on your head at the top of it you have the ability which is like the the main source of it that contains what should be the damage what should be the the effect what should be the the particle or whatever that's the main class that's gonna have all things in it and inside of that gameplay ability you're gonna need to specify two at least two other classes that are the gameplay effect which is what are the effect that this ability is going to have on whatever you know the the target is in the target i mean it could be like another player it could be yourself you could like apply a buff or you could apply like i don't know an explosion somewhere else in the environment but yeah and the effect it's basically containing everything or of you know that disability is gonna you know the effect of the ability entire in the into the world like what should be the attribute that i'm gonna use to decrease or what should be the the calculation that i'm gonna do you know and inside of that effect or the game playability itself you can specify a cue and the queue is basically the particle if you have or the sound or the animation you want to play uh for the target itself or for that ability uh and to create those and i can see that i do have like a bunch of default headers over here i do have my attributes i do have my component and i do have the as i mentioned the queue effect and the game playability itself um those are can be created again in the simplest class components gas you can create the gameplay ability let me just find the actual class of that it's actually gameplay ability i'm not sure why i didn't find it oh it's because i haven't rode so you have the gameplay ability class let me just found that one yeah there we go game playability that's the class you want to create for each ability so basically what i did i create my own custom ability class so i can modify the base of it to whatever my needs are and then i can then later create blueprints based on my custom gameplay ability to you know maybe specify some montages that you can for that ability to set on the editor itself instead of you know setting all three variables or i can specify a data table or anything other sort so i create my custom game playability class also i create my gameplay effect oops i think it's two f's oh there we go so i do have this gameplay effect uh so it's basically my default gaming play effect class so if it's gonna apply something what i'm gonna do with my custom gameplay effect class and i do create also two coups two cues uh which is our this q instant and this q with timer uh so if you type it up like game play q there we go you're gonna have this static actor and this yeah that's notified static and i think the other one what is the other one i forgot the name of it so let me just go back yeah there we go so you have this static and the timer is just a notify actor okay so yeah so q there we go you have this notify actor and you have the notify static so once is one is the you object and this notify static is basically for those sort of effects that only happens once for example like a heat animation or uh i don't know an explosion or an effect that's just gonna spawn and you know uh kind of deletes itself after this pawn it's just gonna play the or a sound or anything of the sword like a hit effect or something so this is like for those events that's gonna happen only one singer game and the notify actor is actually the cues or the effects that needs to be spawned and you can actually it's actually an actor that you can control into the world but uh these are my more used for uh spawns that needs to for example buffs like potions that needs to be or uh stunt or anything any sort of effect into a pla into an enemy or a player that let's suppose you hit the player and he's gonna be poisoned for five seconds the static is not gonna do that because once it's spawned it kind of destructs itself after hits flow but the actor can control like okay after five seconds destroy itself so the character is going to have that poison state into it or that stunt or you know being slow or something like that it can control that it's really modular uh so i create my custom two as well for the actor so whenever i need to spawn like a a potion in the future or some buff effect i'm gonna use that one uh and the static is just for hit the facts or you know animations or things of the sort okay there are a couple other examples here so you can control like even sounds or as a gameplay i kind of gamepl from the rpg uh system but i don't quite use it actually but it's just here so in case later i can i want to use it and to be honest with you guys those three or four classes they are built on c plus plus but there are the whole game playability system after you set it up into c plus plus became more blueprint than ever and because this is made to be user-friendly at least in my conception so basically you construct your your custom ability you can you construct like you build your custom cues your custom effects but uh you create like a base one and based on that class you created you're gonna create like a bunch of other blueprints with customizations for it so that that's at least how i feel i felt it's been built for so okay let's just go back to my game play ability which is basically the the main class of it so for my ability assistant for each ability i specify that the ability needs to have a montage which is basically the animation that the ability is going to have it so i set it as edit anywhere i can set it up these as well through code or whatever i need it to and the category is going to be ability i set it up as well my input my custom input again as i mentioned i set it up a custom variable at my default header so i'm gonna use that inside of my game play ability to specify what should be my input for my ability so if i specify multiple inputs over there i can enter my ability and into the editor just to specify what should be the event or what should be the input that i set it up into the that project settings to trigger that ability so by default it's going to be none but you know just saying that you can specify it that way as well i specified this as well this way event task it's going to be visible anywhere you can also write i'm going to explain what should be event in a couple seconds but uh what's the event that's going to trigger that why should you know what should you do basically each ability is going to have an event and once that ability ends you want to destroy that event basically otherwise you might have like a bunch of actors going on into your uh i mean if you're your project is pretty simple you might you know don't mind but if it's bigger like a multiplayer a lot of uh events popping up might decrease performance uh okay so this is like a function that i create just uh as a blueprint implementable event too so i can set it up my own in montage for my basic ability remember this is my basic ability like my melee combat ability like in my default ability um i'm setting up uh to set the montage at the blueprint level because depending on what sort of weapon my character is using it might change what type of animation what type of melee combat i'm gonna use it for so in my case i'm setting up like a melee combat like a punch ability so if i'm using like a sword i might not my melee attack is not gonna be a punch it's gonna be like a sword attack and if i'm using like a bow and arrow my basic attack it's gonna be like an animation of someone throwing it like an error at someone so i need to specify like a more modular uh animation for that so i create this blueprint implementable to do in blueprints because it's a lot simpler than doing in staples plus and i set up like a bunch of custom events so basically i also have my my owner like it's like a protected so it's not going to be used anywhere outside of this code or once casting but uh it's basically usually only c plus plus so um but basically this functions over here this virtual which is basically overriding the the gameplay ability functions are activatability so what uh how what what is done when i activate this ability once i once the ability is ending what should i do uh commit remember commit ability is uh applying the cost of that ability uh into the owner of it cancel ability is what should be done once i define that ability that is being casted should be canceled and pre-activated is basically before activating my ability what should be like before you know activating the ability what should be should we do of course you could do that into the activate ability as well but i do have a specific use for this pre-activate ability which is setting up my montage basically so if i open up my functions you can see that i set it up like a default montage which is basically my punch montage so i do have a montage somewhere here this is like a blueprint class based on that header file like that class that i just created so you can see that i do have like this punch ability uh once i create that blueprint this is already filled in for me so i at least guarantee that i would have a valid montage right at the beginning of of each blueprint but basically this is like a simple you know punch of the character itself like just punching so let me just leave it open just in case uh okay so this is what's been doing in the constructor i set it up as well the default uh to be the punch now that i'm seeing i think that i should even you know delete that because that there's no need for this because i'm setting the punch to be the default one oh there nevermind i'll leave it later i can delete it um i'm setting it the reference for the montage and the reference i just grabbed it by uh finding the montage itself and clicking with the right button and copying reference and that should be about it so if i paste it over you can see that it's the same path and if the ability montage is no i'm loading that reference uh like loading the montage itself which is basically like loading an object object based on the reference path it's not ideal doing that in c plus plus i'm just doing to the sake of it okay make sure that at least i'm gonna have like a default uh montage for my each ability you can change it in the future but at least the default it's going to be filled in and into the pre-activated ability i do need to grab my player itself so if my player is actually the one that's been you know casting that ability i'm just calling my um set any montage event which is basically this any montage event and passing the state type like what sort of weapon my character is actually using so i just grab it what kind of weapon i'm using which i actually um specified through uh specified through uh through the code itself like somewhere in my code i specify what kind of weapon my character is using so if i'm hit and play right now i don't have a weapon but what right now i don't have even a weapon system actually but once i i create a weapon system i'm going to change that variable to i don't know um sword or shield short sword and shoot or i don't know bow and error or some something else to modify this for me and into my ability whenever this event is called oh not this one but the onset and the montage which is my custom event i'm sweating on my variable like and based on that i can set my anime montage and this anime montage is nothing but a random internet so i can have some sort of variation for the punch uh montages as well so basically what i did i created like a function i specify what sort of montages i wanted to so i have two four different sorts of montages for my punch and i'm just you know grabbing a random one and based on that i set my ability montage variable and you can see that if i play sometimes i do this punch sometimes i'll do another another sort of punch sometimes i do a different one and so i have some sort of variations of puns based on like a sort of random picking of punch as well which gives me a little bit of variation for the melee attack the default melee attack so that's how i set it up the pre-activate so before i even activate the the montage just you know be sure that you have uh um a montage set to it a proper multi set to it so i add a little bit of variation with it uh so whenever i activate my ability i do also cast to be sure that i'm the owner like my character is the owner and i double check that i do have a world and well that's basically what's gonna be done whenever you cast your ability so i'm also checking that i do have like an animation instance which is basically my nimble print so if i do have an animation instance okay so um whenever i do start a montage i add this dynamic like attack and that's why i haven't used that um custom class that it already it's already on there we go that's class display montage and wait for event you could do that on the blog print side you could just like type like play montage and wait for event which is basically what's the purpose of that c plus plus class from the rpg system which is basically allowing you to select the montage i'm playing and do everything on the on the blueprint side but i wanted to give it a shot and try to do that on c plus plus so um only level designer things are done into the blueprint and code logic is mostly hit like handled through the simplest plus so instead of using that i use the default play montage and once i grab the animation instance which is basically the nimble print and whenever i start a montage i attach a anime montage start with like a couple a a function that i created for and the same i do for the animation end which is those functions as well are again as i did in the past for the on taking the damage on the previous video video i just went ahead and find out let me just win there we go where is it oh it's on the top i'm sorry it went down so basically those events if you click on it you're going to find the delegate for it and you're going to see what should be the type of what should be the inputs of each function in order to work and the same goes for the unmontage end now it has two inputs and deploying out is also has the same sort of inputs so that's how i created those two functions and almost i started it's what should i do whenever i start an animation montage and the ending it's whenever i end the animation montage or blading out is whenever it's you know uh ending the montage it's like at the end of its life course so whenever it's at the end of life of its light course i'm going to consider as ended already um so basically i'm calling this function on and it starts whenever i started so which is basically not allowing my player to dodge whenever i because that's going to be weird if i'm punching someone i shouldn't be able to dodge a punching because i'm already punching there's no you know it's kind of difficult try yourself to punch something and you know roll over someone else it's kind of gonna break your arm uh so i said my player cannot dodge whenever whenever he's trying to punch another another player or casting an animation he cannot dodge whenever he's casting an ability i'm using the punches as an example because that's the the only one that i created for and whenever is ending or bleeding out then i'm setting the player to recover stamina because the punching is going to take some stamina for it from it i'm going to show you in a couple seconds how it's going to do it and i'm setting like okay recover automatic stamina so each punch ability is going to take an amount of stamina but the recovery player stamina is going to happens automatically so basically it's going to set it up like a world timer so and it's creating like a an effect and what's doing is setting the timer and each one second it's going to recover some sort of estimated stamina for it and whenever we already hit the amount of max stamina we're just gonna you know clear the timer and stop um stop uh recovering stamina so it's basically what it's doing it's just like a doing a recursive call and i'm going to explain in a couple seconds what are those effects and how you can create yourself but basically that's what it's doing at the top of it so it's calling recover stamina set the player to dodge whenever he finishes uh it's animation and whenever he finishes animation i'm calling this k2 and ability which is basically calling this uh endability function but the difference is instead of calling end-ability with all of those inputs i don't kind of care for who you know all these inputs so if you call on the blueprint and like end-ability for example you're going to see that you have this end ability without this any you know any input and that's how you could call it this node into c plus plus it is just called a k2 inability which is going to basically call this uh and ability function okay but okay so whenever i activate it i already set my my my dynamic binds to the montage sections of my an emblem friend and based on that if we can get the attributes and we're not punching already and we have already enough stamina then we're gonna cast the skill itself so i'm basically get gathering three attributes to be sure that i do have attributes into my player i'm gathering if i the player can actually dodge because he might be casting a skill on top of the other skill so he he cannot cast any skill because he's doing already one and i'm checking if the stamina it's above my threshold which is basically the max stamina uh which is basically like over 10 basically so if all of those are true and i don't have any animation montage already playing because otherwise would you know stop one montage and play another it's gonna be a bit weird and if we're not have any montage playing then we're gonna just play the montage which is the ability montage that we set it up into that variable and we're going to disable the input as well so the character cannot do anything while his you know his like he cannot move forward he cannot we disable the input basically and we commit the ability the compatibility again is what i said it's what are gonna cause the cost of that ability uh to the character itself but it can be called like comm ability that's why it has this k2 it's because it doesn't care for any inputs because if you look at and you cut the compatibility it also has like a bunch of inputs so whenever you want to call without caring about the inputs that are going to pass forward you just can call k2 and the name of it of the function itself otherwise if he's not able to do anything if his uh doesn't have any attributes which means he cannot commit the ability uh if he cannot dodge which means he already casting his skill and his if his stamina is not enough he's just gonna end the ability right away he's just gonna you know kill the ability and not doing anything so that's how we deactivate ability for my abilities handling is just basically grabbing checking if he has the amount of stamina required for it which is basically above 10 percent checking if he's not uh casting one ability already and he has uh sorry he has the attributes to actually commit that ability uh the end ability on the other hand is remember i disable the input whenever i can successfully cast the ability so the end ability is actually gonna enable the input again for me so whenever i finish casting ability i enable the input so i allow the player to cast another ability or even move around again and if i do have an event task which is basically sorry my throat's a little bit uh i have a little bit of sore throat but never mind uh so if i do have a an event uh task already moving around of the ability and it's valid because it's alright you know we haven't killed the ability already so if that's valid we want to be sure that we kill the the this event task we end that task so yeah that's basically what it's doing also so it's basically just enable the input and ending the task if that has been ended already automatically by the ue4 the comm ability is not doing anything because remember this is automatic so whenever you set it up or your ability to use a specific attribute and you apply the specific effect that effect it's going to set like specify which is the cost the effect is going to handle all the math for you uh and the cancelability is also not doing anything because we're not caring about any cancel right now okay so that's the ability so that's the default ability so any ability that i have basically it's gonna disable the input and only enable at the end of it and it's only gonna be able to cast if i have enough stamina and i'm not casting any other ability that's basically what it's doing i know it's a lot of code for it but yeah and also it's setting the default or a variable uh for the animation that's gonna play based on the kind of weapon it is holding okay so that's the ability but if you open up the ability itself and you go for the class default you're gonna see that you do have like this cost section of it which is basically remember i mentioned uh uh the ability is gonna control the the source of it but uh the calculations and everything behind it it's gonna be like all the damage deals or all the uh all the calculations like what's what are the costs what are the damage is gonna be handled by a fit and the effect uh you can specify by the gameplayflex class i created like this stamina dropper hit so it's like an effect like a simple one so you can see that it's a blueprint but it's based on my custom if you open up like as a full editor you're going to see that the class settings is like it's a giz effect and if you open up the the effect itself it's based on the you gameplay effect so you create like a custom class i did just set it up like a header for it and like i had a sorry a constructor for it and i set it up like the default duration to be instant and the period value to be like to have no period like this should be the default like uh just a an effect that is applied once and it doesn't stay forever so uh you could do differently but basically the effect it's entirely easier to do everything through blueprints so i can create this effect and if you go to duration policy you're gonna see that you do have like a modifier and here is where you specify you can add another one it was it's gonna be empty for you if you wanna your effect to you know change multiple uh attributes of your character you can specify multiple ones but in my case i just want one i just want once so this effect is called uh stamina dropper hit so whenever i you know call a punch i'm going to drop a you know my stamina is going to drop by some sort some amount so i set it up to drop my stamina okay so basically uh it's grabbing my attribute stamina and it's grabbing based on uh on the attributes i set so i set it up like stamina attribute the modifier is going to be add or you can multiply by two or whatever divide it over it but add and if you go to the magnitude what i'm doing is i'm grabbing like a scalable flow which is basically like a float value so whenever i hit call like a punch it's gonna drop minus like it's gonna add minus 10 which is basically subtracting minus 10 of my stamina so if i open up my blueprint again and again those blueprints i just created by this like blueprint class and i since i do have my c plus class i can just type gas and i do have my gameplay ability which is basically my c plus class that's how i did it i just named it afterwards and the same goes for the effect so i set it up i need an effect select over here and on the effect i set it up that this is going to drop 10 uh of of stamina for each punch i throw so this is going to be the cost for this ability specific you can add multiple costs as well so you can drop down on your stamina you can drop mana or you can drop whatever you want it to but for disability which is a simple punch i'm going to just drop the stamina itself and this is going to cost for the character that is casting it's not uh what it's gonna cause to the target for it so cost is gonna what the target the target is like the enemy and the owner it's gonna cost something to trigger that ability you don't need to you have a cost but in my case i wanted the cost to be stamina so if i play here and i open my console command and show debug ability oops system you can see that uh let me just see if i can make that a little bit bigger i think that's gonna be bigger there we go uh so show the bug ability system you can see that yeah it's pretty small yet but uh let me see if i can open up the software that yeah there we go point to fix so um you can see that here are each one of my attributes basically including the floating ones that i set it up and you can see that i have stand-up strength i can i have like 100 of max health or whatever and i set up this on the default constructor but uh if you open up your character me just open up my character blueprint really quickly and i search for attributes i have my max health max max value of each one of those set it up over here so that's how i set it up for the level designer to specify that's why i set it up as a float not as a gameplay attribute data over there because otherwise it's just going to have the variables but there would be no way of setting up that easily but again if you play it up and set you debug ability system you're gonna have over there my attributes and if i punch you're going to see that that attribute is going to drop oops i don't think i'm in the console commander okay and if you punch my stamina went to 90 and now it's getting up and up and up because it's recovering itself so if i punch one two three four you can see that the stamina is dropping but each one second is trigging triggering like this increase of stamina so it's kind of hard just decreasing by 10 you can punch a lot basically so it's costing something you can see that is working because once i cast on my c plus plus uh whenever i successfully cast my ability and i need to open my ability again uh component ability where is it there we go whenever i successfully cast my ability i do commit my ability so this commit is basically going to grab that cost a section of the effect and apply whatever i set it up as the effect for the for the ability itself so that's how you set it up effect basically it's pretty simple pretty straightforward uh okay so but if you look it up and i'm gonna present you really quickly if i punch it a character you're gonna see that he does he does have this sort of animation and also you can see that i move forward a little bit each punch i give and the same goes for the character that moves in the opposite direction which is i think it's called knockback effect i don't know how you guys call it but uh uh how i do that is if you open up like the effect itself let me just open up again you're gonna see that below of it of the effect let me see if i can find it where is the ability okay so i do have the ability to cool downs and etc okay so the effect has been called and basically what it's doing is it's triggering this animation blueprint and you can see that each montage has this notify name punch montage which is basically where when i should apply the damage to the target so basically it's just playing the animation and the damage itself is handled by this i need notify and whenever i finish i call this reset attack which is unneeded at this moment but uh yeah and i think i can even delete it later but since i do reset the attack at the end of it of the montage on the c plus plus already but uh at the beginning i was using blueprint so i had to reset uh the attack if every time the any montage finish okay so this blueprint itself let me just go back to the blueprint it's also uh it's in a name modif notify so if i open up the c plus plus class i created also on any notified c plus to handle all the math like for the damage itself so basically what it's going to do is going to have let me just open up the header i think it's going to be easier to explain so if you open up here on the c plus plus you can create this third row plans blueprints but again i mentioned all the logic i like to do in the c plus plus and you know things that are you know uh level design ways like a level design uh option like what should be the particle what should be the animation whatever i leave that to the editor so the level design can level design can specify those into the editor itself not bothering at all with the programming logic behind and also it's a lot cheaper on the code side as well to do that on c plus plus then you know do mapping and blueprints uh but basically what i did is on the gameplay basis gameplay ability system folder i've created this let me just find it i think it's on the notify yeah there we go inside of my character i do have this abilities i need notify i do have my melee modify which is like you and me modify so basically what i did is i searched for unnamed notify and i select the first one and that was it uh so basically it's the same as if you were into blueprint and you create like a blue brand named name notify should be the same but basically what i do on this name notify is if you see the code itself there's nothing in it but i set it up like for the level design to be able to set the trade like what should be the knockback strength of both characters and anime and the camera shake effect which is basically like it's really not that noticeable but uh there is like a small shake on the camera as well whenever whenever i throw a punch uh it's really like the detail but the character level design can specify a different effect uh what should be the trace radius which is basically is tracing on the on the hand socket which as i specify here as well and and based on that radius is gonna grab whatever is you know around it and it's to send a tag for me which is health damage so what it's going to do is going to send an event to my gameplay ability system which i do here on whenever i activate the ability i do wait for a gameplay event which is basically set it up like to wait for it health damaged event and whenever that happens i do apply that melee attack effect to whatever the target is so what this is doing is basically on my name notify if i open up the notify itself let me just open the and those are blueprints that are you know again uh it's out of ultra blueprints i just set it up those variables over here and i overrided the notify function and based on what it's doing is casting to check if it's a character that i'm hitting so if it's hitting a character that's going to be the target so i do not apply the target to anything else other than characters you could apply that to you like static meshes or destructibles or whatever but for this sake of this tutorial i'm just applying this to characters uh so if i do have a reference a reference uh i mean the owner is the sorry the owner is the character which is basically us and if i do have the owner and the owner also have a world what i'm doing is i'm creating like a trace and what it's doing is like just doing like this overlap actors trace and it's grabbing the socket and whatever and whenever whatever hit found it's gonna you know save on this variable extra and it's going to ignore the owner which is basically us so it's going to ignore us and basically what he's doing is applying this impulse strength to like the direction of the pulse is going to be the only reference the capsule component like the front the front of the capsule component multiplied by whatever is the strength that the level design specifies so if you specify like a thousand two thousand it's gonna move even more uh forward uh basically what it's doing now is for each one of the overlap actors sound it's gonna uh create this target handle which is basically how can i explain that as a like it's creating this let me just find here on the create something like this but uh let me see if i can find that to be a lot easier basically ability target for actor is like a blueprint variable that you can see ability target from actor there we go so it's creating this note it's creating like this return value to set it up as uh the target for this variables okay so that's what i'm doing on c plus plus i'm creating this uh target for that overlap actor to set it up what should be the event to send uh the event data and set it up like an empty one because i don't need it uh the instigator is the owner which is basically the character is triggering the punch the target is whatever the actor is overlapping at the moment which should be this overlap actor uh the target data is whatever i created like that target data from actor which is basically over here which which is just what i created based on the overlap actor and i am sending this gameplay event to actor which is basically this send gameplay event to actor so i need to specify an event tag which at this point they specify the health and damage which is basically the target the tags to send specify on this point here so it's going to send that the gameplay event data is going to be basically everything that i just built with the reference what should be the actor and what should be the target uh to apply and the owner reference which is basically the one that is the one that is actually applying that event and if i do have an enemy which means like i'm only applying that to an enemy like this is only applying two enemies so if i do have an enemy uh based on the overlap actor what i'm doing is i am adding the knockback effect so they're not there's no point of applying knock back effect from on a wall or maybe an object might be but uh um i'm just adding the impulse uh if i do have an actor basically the knockback effector the fact only makes sense for me to an actor to a character sorry so if i do have an enemy character i am applying the knock back effect which is basically adding an impulse doing the same thing as above but based on the character movement at an impulse and that should be about it uh also i'm calling the camera shake here so the under the owner i am also i'm not only applying the knockback effect to the character i'm applying pushing the character a little bit forward as well in the same proportion as the as the as the punch and as the enemy and i'm also grabbing the gameplay control uh the gameplay controller and i'm playing the camera shake and that should be about it and i'm doing this before the super it could be above below it but after but whatever uh so basically what i'm doing is i'm making a trace and based on that trace and also i'm calculating what should be the strength of the knockback effect and the impulse direction of my character and for each one of the overlap actors that i found i'm gonna send the uh event uh health damage which is basically applying damage to it and based on that i'm setting up the the tags to send and if the overlapping actor is an actual an actual character i'm also going to apply a knock back effect to it and i'm going to move my character a little bit forward based on that and apply on camera shake you could do that on blueprints as well but uh i found a bit easier to just specify to the level designer all the parameters that he wanted to where he wanted to start the trace what should be the radius of that trace what should be the camera straight like it's a lot simpler for a level designer to just bother about statics than you know gameplay or whatever in my dirty his uh his his view and then what i did was basically i am on that i created this on the ability system whenever he activated on the and i didn't found like a way a good way of uh linking that to c plus plus i would love to if you guys have any any way of doing that but uh i found a way of starting the work but i haven't found a way of reliably linking those event and uh dsx is basically after uh right after calling it but the event received i haven't found like a reliable way of linking that through c plus plus code so if you found that out let just hit me up and that might be useful i might convert that to c plus plus as well because i don't like like i don't like coding logic to be into what should be level designer work dirty work i mean it might be a bit confused by looking to this so basically what i did is whenever i receive that event i wait for that event to happen whenever i activate the ability and he waits for the health damage event and i set it up that and to that war weight event task so whenever remember that we have this uh on the ability we ended up the task but we never set it up that task in the first place that's where uh we set it up that task which is after we create the ability we set that event gameplay event task to our variable and that becomes valid so whenever we receive the event that's going to grab the payload and the payload is going to have like all all that basic information from our uh punch damage notify that we built so it's basically going to have all of this information into it this gameplay event data and this is going to be the payload and we set it up to apply effect to the character to the target itself and the target is going to be our gameplay event data which is basically like our target which is basically the overlap actor or actors and what is going to be the effect that it's going to apply it's going to apply this effect which is melee attack damage effect and again same similar to what we have to the dropper hit effect we're gonna have the melee attack but differently it's gonna be instant as well but it's gonna change the health only and the health let me just is adding as well but the magnitude is attribute based uh which means that the amount of health that's going to be decrease of the character itself it's based on the let me just found the attribute base that i used oh there we go so it's based on the character's strength so if my character has uh 10 strength it's going to decrease i put it minus 1 because i don't want to increase the enemy since it's adding i put minus one because it's going to be multiplied by minus one the value so it's gonna grab the character's strength and it's gonna subtract that from whatever the target is so if my character's strength is 10th is 10 it's gonna decrease 10 of the enemy's health it's my character's strength is 20 it's going to decrease 20 so it's going to be based on my character strength only so that's also a good way of doing is instead of you know setting up uh [Music] setting up like constant values over here like 10 so this way you can make your game more granular so based on the evolution of your character based on the upgrades that you put into your character your strength is going to be higher so your character is going to be stronger and you're going to need to have stronger enemies in order to you know balance your game a little bit so that's how it's going to work uh there's no tag there's nothing in it so there's no source tags or whatever let me see if i can find oh there we go though on each effect and remember whenever i play the notify it's just uh moving the character or the enemy putting the knot back effect though i am never and you can see that i have never informed that the enemy should be playing this animation or maybe i would like to spawn like a blood uh particle or whatever and this can be done by the gameplay cues which is basically the visual effect of this whole uh gameplay ability system of course there are no d some may say that the montage is already like a visual effect and i agree with it but uh uh i would say that particles sounds and animations those are also part animations already is part of the montage but yeah this is handled by the gameplay cues uh more should be handled by the gameplay cues more often so if you go to the game like on the under the gameplay effects section you're going to have the display uh down down below and you can see that you have like game gameplay cues uh and you can see that no no there's no place where i specify this gameplay key like hidden reaction or anything of the sort but i specify like a tag to the gameplay queue hit reaction and you can see that doesn't present the other tags because uh this is a gameplay queue tag so whenever you enable to your gameplay ability system you're gonna see that there's like this gameplay queue editor where you can specify new tags and even creating already handlers or uh gameplay queue blueprints for it i created mine in c plus plus and you can see that if you click it open you click here it's going to open up for you but if you open up that window again and you want to create like a new one let's suppose to create like a new one like gameplay queue whatever you wanted to like i don't know stamina slower whatever and you can comment over here and you're gonna need like a new tag and you're gonna present to you like add a new gameplay queue notification or gameplay you'll notify actor and remember uh this is gonna create under your game like in gc that's gonna have like under the game folder i don't like to do it that way i would like to just create the the the tags over here and whenever i want to create like a gameplay cue i can just go back to my skus and open the cues section i rather just go to blueprint class and fight find my custom gameplay cube with timer which is basically if i wanted like a a a like a effect a longer effect to either enemy or the character like that should hint like should do you did that effect for a couple seconds or should stay for a couple seconds or i can just hit like this as an animation it's just an instant one i can just create that one and uh how to how do you link that into that editor is just basically under the gameplay queue itself you can specify the tag as this one for example and if i specify that that way and i open up that window again you're gonna see that you just switch it that's how you uh specify that so you link that through the tags itself i rather link that way than because i like to create my custom ones then you know doing manually uh just creating like because you you're gonna need to create like the default gameplay cues and if you wanted to create like a custom down like a custom event on c plus down the line you're gonna be you're gonna you won't be able to because those are blueprints uh though that way you can specify some custom informations on c plus plus later like this hit reaction as i said specify on my own so if i open up my gameplay queue not the timer one but the q instant you can see that i create this variable name what should be the montage like the hit reaction montage and i can specify what should be the montage to play uh the tag needs to match exactly the one on the effect so it's just a matter of telling to the display section of the gameplay effect what should be the visual effect of that of that uh effect itself and whenever that effect is triggered it's gonna try to match exactly with whatever gameplay you already have in your game and basically what i did here is just i just let me just open up here i didn't do anything on the on the c plus plus at least not just yet because i found that right now since i'm prototyping things i like to do that way because it seems a lot a lot more simpler to prototype than later i just you know move over to c plus plus whenever i need it so basically i just override a function here named on execute you have like a couple other ones all of those functions you can override as well in c plus plus but again it's just prototyping so i cast the character itself and if the player is alive and again this is a function that i did i created on my player like together like a blueprint peer function so if i open up my character here really quickly uh let me just open oh i open up the wrong file let me open the header so if i go back to ease player there we go so you can see that i do have like a forcing line function name uh it's blueprint pure which is basically this split blueprint pure okay that's a lot a lot more english so basically what he's doing is just returning my b's live function so that's how it's going to look like and it's it's it even has this uh comment whenever your mouse over because the way you comment the function itself you put like those two asterisks it's gonna [Music] it's gonna put that comment into the blueprint function which is pretty cool so if my player is alive or which is basically like the target not my player but the target of that uh effect which should be like the enemy if that player is alive and if it's a character and if it's alive what i'm doing is i'm playing a montage and the montage i'm playing is whatever the level design is specified and that should be about it and i'm just closing it up like as if like i'm just finishing as a success i would like to put that as well just in case i'm not hitting like any um any character but i would like to kill this gameplay to kill this gameplay cube whenever uh i you know trigger it so that's how you put effect like visual effects into either character or into the screen whenever you do that that's gonna wait for that tag and event to be sent and there we go dude that's basically it and whenever he hits to the point that he gets less than like he's dead well then my animation blueprint is gonna say okay disable the input or whatever you can you know do your thing just grabbing uh the character whenever you're sending for example what i did basically is on my attributes let me just go back to the attributes class or is it my attributes class uh attributes let me just open that way okay so whenever i set the health attribute uh well if the health is minors or equal to zero then i'm setting the players alive to false which means the player is killed either it's me or it's an enemy or whatever and basically if i open up my blueprint my animation blueprint which is also in c plus plus but uh let me just open up my characters playable and in blueprint you can see that in the event graph there's nothing in it because all of those is handled through c plus plus it's a c class so if you open up my characters playable you're gonna have this and festival a name instance so it's basically a on name instance class so if you open up this class over here it's just a new u name instead of class so if you new class instead of creating like an animation blueprint i created this an instance class name it whatever i wanted to and inside of my name instance i do have this constructor and this native update animation which is basically whenever you open your name blueprint let me just open up the implement let me open the the the ue4 and in blueprint to make it simple to just to present to you guys let me just try to open that animation blueprint okay so if you open up that animation blueprint you're gonna see that you have this blueprint update animation and that node in simplest plus is called native update animation that's basically it but i just overwriting that and i'm doing all my logic that usually the uh ue4 does on blueprint for beginners and for everyone uh they usually usually do animation blueprint i do that on c plus plus because depending on the complexity you want to get to your game that they become it may become a little bit heavier and i do like to make calculation then doing that on c plus was a lot cheaper cheaper to the engine itself i do have my properties for the whenever i needed to modify something on the animation blueprint like player reference weapon being used speed is alive and this is a live is basically based on that is alive variable on my character if he's on the middle of the air if he's casting skill or whatever and i do have also this update animation properties which is basically getting the velocity or whatever and what's doing is on that native node what it's doing is casting to the character and this is basically this try get owner so it's basically the same thing i'm setting this as a reference and if that's true that means i can update my animation uh with my animation variables that i use for for the animation like speed uh if the character is in the air ifc is live and this is gathering that variable that i just said before and what kind of weapon i'm using and yeah that's basically if i'm resetting this hack i'm setting the player that he can dodge through remember that i have that variable on that notify on each animation blueprint but uh it's kind of useless right now because i do that on c plus plus on the gameplay ability directly but yeah anyways uh i do have to do once whenever i want it because there are some sort of things that i like to call this node like do once and i haven't found a good way of doing that on c plus plus so i kind of have this function and if i do once i needed to reset it that's how i do it basically not that i need it right now but i like to have it set it so if i do something it's going to do once unless i reset the ones which is basically this so yep that's basically what it's doing and similarly to the animation blueprints i do have my states like this is the basic state like the basic idol the death and those are all updated based on if he's alive he's gonna present the death if he is not if he goes from he's alive to uh you know revive like a respawn or something of the sort it's gonna be to revive which is basically this animation of is getting up and i do that for basically even like all sorts so whenever i set that variable is live to false it's going to go to that basic state and it's going to call the animation div which is basically that animation that you saw basically so yep that's basically animation blueprints which is not the point of this video we can cover that if you want it later into another videos into different videos but basically based on the weapon being used he's using like basic or he's using like an archer or dual blade fortitude or whatever made the state or whatever not that i have uh uh this all coded but i would like to have at least like the note the animation blueprint already set up so that's how you kill the character and you can see that it's applying i need to give ten punches to kill it so two three because i have ten four five six seven eight nine and ten punches and hayes did that means that my uh effect of the attack damage is actually working based on my strength attribute so if i open up my character and i change my max strength to 20 instead of 10 and that remember that set it up on my attributes so if i open up again my strength starts up with the value that i set it up as a maxi strength on that case i set it up as 20. so now i need to give five punches if i'm not staking on my math one two three four and five punches and oops oh he's not applying what is my basic strength let me just show show debug ability system oh my strength is still 10 okay so it's not applying this modification that i did maybe a hot reload i don't know i'm just maybe it's a hot reload issue let me just let me save it and [Music] start all over to see if it's gonna save it because it's not saving as 20 as i set it up to maybe it's a hot reload issue let me just start all over it's just taking too long to compile okay so yeah okay it's compiling now let's see if it's starting with 20 now show debug ability system strength is all it's already 10 so not sure why okay i need to debug this later but basically that that's how it works uh play your character let's open up it's 20. i'm not sure why it's not setting that up okay but let's suppose you want to change that somehow just begin play whatever get attributes search max there's only the getters okay i need to set it up maybe a way of setting that up but uh basically that's how you would do it based on the stamina it's just because there's a bug here i'm not sure why it's not setting up the max is stamina s20 i need to debug that later but yeah that's how you set it up that basically uh based on the attributes so since my my attributes is saved as 10 it's setting up that as them so i need to give 10 punches i need to find a way of setting up that 20 value because that was the whole intention of this of setting this uh up that way otherwise there's no point of you know change that uh you know through expose that to this way maybe i need to use a data table later yeah again but now how do i give this punch ability to my character that's because i have this default ability as i mentioned before let me just find the melee ability there we go i do have this cl this variable name blueprint really only like edit defaults only as its ability and this is the class for like a default class from my you guess gameplay ability and i saved as melee ability and here i can set it up that simple attack blueprint which is based and create on based on that gas gameplay ability class as my default attack so my default ability to set it up and on my character itself on my functions whenever i give the ability let me just go back to the default uh again setup gameplay let me just go back again i set it up the input here is setting up the input and this input is based on the input that i give here which is punch and in order that for that to work you need to have a input with the same name so you go to the project settings input let me just find it input with the same an exact name name and whenever the the the key you set it up here it's going to trigger that ability uh the ability matching with that and on the begin play i before you know after initializing the ability the ability assistant component i do use this givability function so what this is doing is uh it's grabbing the component and it's giving the ver the class mainly ability to it as a default ability so if you want to do like some sort of skill tree in the future you may need to have multiple classes not multiple variables that way but you need to have multiple classes with multiple game playability classes set up might be blueprints might be c plus classes whatever you wanted to and then you just need to call it give abilities and you know give the pointer to that ability it's specific it could be like a subclass so basically you can create maybe a data table with lots of abilities and what should be the requirements for each one of the uh maybe let's suppose like uh a sourcer like a magician like a magic mage class uh he wants to give the default ability as i don't know uh [Music] fireball maybe that's the the melee combo out of the of the of it but then in order to have the next ability which i don't know spawn uh maybe cast and other uh enemies or control mines you have you need to have uh the fireball active so you can control that by on your ability system you have these tag let me just find oh this is the oh this is the ability so there you go you can have the source require tags you can use that so in order to activate that ability you have to have maybe some other tags here already into your character uh or you can set it up that into your data table somehow like oh only activate that if i don't know you can have for example in my case what i'm going to do in the future is i do have this uh similar to what we have for the armored setup audience that i'm gonna have it i'm gonna have like a tra variable of gas ability systems or something like that and i'm only gonna allow this function giveability to be called uh whenever an ability before is already inside of that array if it's not inside of that array i'm not going to allow the ability to be given basically so in there similar to what skill 3 works so you have the basic ability which is the punch or melee ability and above you want to upgrade in order to upgrade you need to have uh inside of under your array of abilities that ability in there already or in order to upgrade to the above one you need to you know have the below one inside of the array so that's how i'm gonna do it i'm not sure if that's the best way but that's how i'm going to do it or you can use those required tags so whenever you want to kind of spawn that if you already have that you know amount of tags and spawn somewhere inside of their level but i think that's a bit troublesome but like activation required tags uh yeah i think that's that gonna become a lot of tags on top of the other tags and it might become a lot confusing confused uh to level designers to work with but yeah that's how you would set up gameplay abilities and for testing specifically on the session front end again i do have also unit tests for it like yes unit test attributes since i don't have any magic points those stats are going to fail since i haven't implemented that you can see that it's kind of failed though the health tests like if i can kill the player probably it's going to pass because i check that i can you know decrease the the player value and i can kill it i check that i can decrease and apply like a target effect to the player itself i also check like unit testing if that i can change the flow attributes never negative and never met over the max layout so you can see that there are unit tests for those and also on the functional test side of it because since some of the again some of these game playability system uh attributions are at least it feels like they're built to be on blueprints at least more user-friendly for not only people that handle c plus plus but also uh you know more user broadly for level designers or something like that they may need to they might not be so familiar with uh c plus plus or any coding language they might be able to use that just by setting up the component and that uh integrate like that setting up the attributes and the components into the player character and then later doing everything on blueprints uh so if you like it was built to to be user friendly that way uh so for end-to-end tests like testing that you can actually cast the skill or apply a damage or anything of the sort most of that needs to be uh tested at least once and the end-to-end level so i do have this project settings functional testing i do have this test that i check that i can apply a damage to a character like and that i can decrease the stamina after calling uh that punch ability and since that's an end-to-end test i kind of don't care i explained uh last time that you can also write end-to-end tests on c plus plus as well but uh i kind of don't care actually for entrance tests on c plus plus at least for this specific component because uh since most of it it's already built in blueprints why not testing in blueprints i mean of course it's going to be difficult to maintain that depending on how big the project is but since this is a standalone program that only i i'm gonna work with right now since it's just a you know a simple project i just created like two blueprint testing for it so i created like a game vote a game mode test which is basically set that up like the default pawn class to none otherwise it you know it would spawn every time i try to play a uh every time i try to run a functional tests it's going to spawn like two players the one that is on the map and the one that you know uh the one that is on the map and the one that you shouldn't spawn by default so i let them just open up like a map test for example like map dev test let's hope this is stamina test for example so if i want to play i don't have any anyone to spawn because this is a task map so it's not going to spawn anything so my view is going to be pretty and again as we did in the last time for cps plus it's just a matter of setting what the character reference what should be doing and you know the task itself is pretty simple pretty self-explanatory so you can create that on the blueprints as well so you can find functional tasks here there we go that's the same way you did it for blueprints but the difference is whenever you open up the test uh when you start to test you're going to do something and then you tick in the same way you did uh in the same way we did the last time i'm gonna check if something you know finishes or or not and then basically quitting the game and finishing the test basically what this is doing is uh it's grabbing the reference which is basically the characteristics the character reference i set and it's trying to activate an ability by class and the ability that i'm trying to activate is the ga simple attack which is basically the melee attack and if that activates successfully i'm gonna fix er if that doesn't activate successfully i'm gonna fail the test because i have been unable to cast the skill and again that's only gonna be able to activate because uh on the begin play of my character i set it up on the begin play of my character i've set it up that to keep that ability by default so be careful if you don't give the ability it's not going to activate so that's going to fail so maybe you need to mock something else to be able to either see plus plus or build up mock something else to to your character in order to provide that ability to test to him like maybe you should uh probably like give give ability before it like find a weight of giving ability oops yeah there's a way of doing it i'm just not finding on the test level at least a lot of blueprints but i know that you can call this givability function oh yeah it's because you you need to on the header you need to set the interface to it so maybe you need to the class default add an interface to it as well on your test level in c plus plus that that is interface for your test as well in order to have those givability functionalities here just be sure that you have that ability and then uh if it doesn't cast it's gonna fail and quit the game if you're the test and if you cast it's gonna grab the stamina set that to a variable like stamina after the effect and on the tech it's just gonna wait uh onto your stamina after if the effect is less than the actual stamina so it's actually recovering uh stamina after hitting the player or doing something else so yeah that's basically what it's going to do this test and the same goes for the damage damage is similar to the other one which is just going to move the player around until here and again just don't forget to set your game mode test as your you know the test the test game the game modes for your levels so you just need to go to word settings i'm just trying to find that out here where's the world settings uh world settings where is it i remember seeing that somewhere here oh settings okay here world settings there we go and so set your game mode test uh so you don't spawn player anywhere whenever you're testing your code and move your test functional test to the level and then just her to test and that should be about it move the player pass and he it was pretty quickly but he actually gave a punch and after one second they after a few seconds milliseconds they recovered the stamina right away and that's about it i hope you guys enjoyed and see you next time
Info
Channel: Unreal4Pro
Views: 1,750
Rating: undefined out of 5
Keywords: Gameplay Ability System, GAS, Unreal Engine, UE4, UE5, Test, TDD, RPG, Ability, Abilities, System, Effects, Cues, C++, Blueprint, Class, LiveStream, Live, Streaming
Id: n-8RJMHbLfk
Channel Id: undefined
Length: 112min 30sec (6750 seconds)
Published: Mon Jul 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.