Godot 4 Hack and Slash #1 Active Skill

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys this is Johnny and in this video series I'm going to create a hacken SL demo using Godot the source code of this project is completely free and you can download it from each this project is made on top of my go. 43% controller demo so if you haven't watched the series I recommend you to watch that before you start this one the hacken SL demo will contain these features for now but the list might get changed as I make progress as you can see the features list is very straightforward and also you're welcome to suggest any features in the comments I may also add features or fix bugs even after I'm done with the videos so you can stay updated with those if you follow me on each in this video I'm going to show you how I'm making the active skill system which the player actively delivers I could name this character skill but I want to create a more generalized skill system which can be tied to a weapon character or any other objects that way we can change weapons and get different types of attacks from them the active skill will have three phases wind up delivery and recovery each active skill will have their own animations and durations for the three phases I've attached these icon to the class so if I add them in the scene it's easier to see them as you can see I've created this sword and attached it to the character using bone attachment 3D in the active skill script I've added some essential variables and a little bit of code which I'll explain as I go through this video here I'm going to add this node which would contain all the skills of this weapon I'll create a script called skills container which will be responsible for activating the skills in the animation tree I've temporarily replaced the animations of the upright sance with the sword animations I'll modify this section when I'm making the weapon switching system I'll add this transition node and name this attack transition which will show the attack animations I'll be switching between the animations in the code so I'm going to keep two buffers in the animation tree and switch between them so what I'm going to do is if the player is not attacking the end attack transition state will be active as soon as the player starts attacking I'll take the animation name and set it in the first buffer then the transition state will be switched to the node if the player's going to do another attack after this one the next buffer will take the animation name from the next attack and will simply switch to that state so it's going to alternate between these two transition States as the attacks keep going one after the other this way we can make sure there is a smooth transition among the attack animations I'll name this state end attack and these two has attack buffer zero and one for attack buffers I'll create two blend trees and each one will have its own animation and a time scale node I'll keep the same name for the nodes in both of the blend trees so it's easier to create a reference in the code no need to assign the animations here as this will be done in the code using the animation names from the active skill objects in the skills container I'll keep the references to the animation tree and the relevant animation nodes here here I'm keeping a list of active skills available the animation tree will be assigned from the active skill controller script which will will be responsible for calling the functions from the skills container this is because the skills container could be tied to a weapon and the active skill controller would be tied to the character so the skills container might be loaded at run [Music] time I'll asend the rest of the animation nose in the code I'm also going to need some timers to switch between the attack states which will be stored here I'll asend the ready State here as the attack will be allowed only if it's in the ready state here in the ready function I'm assigning the attack transition node and I'm instantiating the time on nodes and connecting them to the individual timeout functions the attack phases are pretty straightforward in the start attack function I'm stopping all the timers setting the current active skill and switching the attack buffer this function basically switches between the attack buffers this line toggles the attack buffer ID between zero and one and here the animation noes are assigned inside the attack buffer which is a blend tree the animation name parameter is found from the active skill class so for each skill object I'm going to set the animation names as there's no combo system yet I'm going to temporarily switch between the active skills one by one for testing and then the windup function is called here the state is assigned as winding up and the attack transition notes CrossFit time is set as the wind up duration found from the current active skill with this function I'll set the transition value of the attack transition node as the current attack buffer and with this one I'll set the time scale to zero zero this way the attack animation will be stuck in the first frame and the character will go from current animation to the wind up animation with the duration value of this the windup timer will also take the same duration and as soon as the transition to the first frame is finished this function will get called in the deliver function the state is assigned as delivering and the buffer time scale is set to one so the attack animation is played and the delivery timer is started with the duration value of this variable from the active skill after the timeout the recover function is called and it's pretty much the same as the delivery function with the variables related to the recovery phase after the time on the state is set to ready and with the end timer the attack transition is set to end attack so the character can return to the non-attacking animation the start attack can only be called if the state is ready so if the attack has reached here if I'm not immediately calling the next attack the last frame of the animation will stay for a moment the active skill controller is a part of the player controller and will be in charge of calling the functions from the skills container here I'm manually assigning the necessary variables but as the skills container is tied to weapons it may be assigned from another controller like weapon switcher in the player script I've added a new signal called press primary fire and added some new inputs called primary and secondary fire which are Mouse left and right the signal is emitted here and here I'm setting the stances upright when attacking the Pressed primary fire signal is connected with this function from the active skill controller and here I'm going to Simply call the start attack function I'm also checking if the skill is active with this function so I can ignore the function call when the skill is already active as you can see the attack animations are playing nicely I've already put the values of the attack phases which you can properly see if I slow this [Music] down so now I'm going to modify some functionalities of the movement animation and the camera controller I've introduced a new Boolean variable in the player script called EAS attacking and here in the camera script I'm returning here so we don't change the fov anymore when we are attacking I'll also move this code into its own function so I can call this later in the movement controller these three functions are ignored when attacking so the jump functionality is completely disabled while attacking also the movement State should not be changed as I'm going to use unique acceleration values for the active skills and the movement Direction shouldn't be changed as well as I want the player to face the attack Direction while attacking I've created a timer called Dash timer and a vector 3 called Dash velocity and here I've created a dash function that takes a velocity duration and a delay value this function starts the timer and sets the dash velocity to the received value the velocity parameter is meant to be in the local space so I'm going to rotate this towards the direction variable which is controlled by the input this line simply adds a delay to this function and with this function I'll rotate the mesh route towards the direction using a twin as I'm going to disable the movement rotation when attacking this will make more sense when I show you these lines in the physics process I'm checking if the dashing is active which means the timer is active and set the velocity x and z values to the dash velocity and if the player is attacking they become zero so when the attack starts if there's a dash delay the velocity is zero at first as soon as the dash starts we switch to the dash velocity if the dash and attack has ended the mesh rotation with movement Direction is enabled but because we're using lurp with a rotation speed the player does not instantly look where the direction is so as we ignore these lines when attacking the attack may not always land where the direction is intended so that's why I'm using this function to forcefully rotate the mesh rout towards the direction using a twin this way I can make sure the attack is landing in the direction I want I'm also using lurp angle here with a value of one as the interpolation so the mro takes the shortest way to rotate [Music] in the skills container I've created a signal called completed recovery which is called after the recovery is finished and in the active skill controller I'm connecting it with this function here I'm setting the player's ease attacking as true and I'm going to set the acceleration value of the movement controller from the currently active skill I'm going to call the dash function and put the parameters from the currently active skill and here I'm going to call the set fov function I created in the camera controller so each attack can have its own unique camera fov value I'm also storing the last movement state with this variable using this function which is connected to the change movement State signal of the player script this way you can see here I can get back to the proper movement state after the attack is [Music] complete I've also added a sord trail effect using an add-on called GPU Trail I'll provide the link in the description for this you can download unzip and add this to your project as this you can simply add the GPU Trail 3D node like this and immediately see the result I've added this as a child here and positioned it like this I also created a simple texture and gradient here in the active skill script I've added this VFX variable so each active skill can have its own VFX in the skills container script I've created these two functions to play and stop the VFX here I'll create a simple scene Tre timer which takes the value of VFX Delay from the currently active skill and after the timeout it shows the VFX node then another timer takes the value of the VFX duration and then calls the stop VFX function which hides and restarts the VFX node the Adon shows a glitch if I show it again without restarting [Music] it you'll notice when the VFX is shown for the first time there is a frame drop to fix that in the active skill script I made this load VFX function which shows the VFX for two frames and then hides it this way it loads as soon as the scene loads and now now you can see there are no frame drops on the first attack
Info
Channel: Johnny Rouddro
Views: 3,481
Rating: undefined out of 5
Keywords:
Id: 5oMSJFczcOE
Channel Id: undefined
Length: 10min 39sec (639 seconds)
Published: Fri May 31 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.