Tutorial: How to create melee attacks using AnimatedSprite! (Godot Engine 3.2)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] not too long ago I uploaded a video on how to create combo systems with melee attacks but I never went explaining how to create the coalition's that will actually clash with the enemy so we'll do that today not only that but this tutorial will focus on guard user set utilize animated sprite in favor of the arguably more popular animation player there's already a great tutorial on melee attacks is an animation player made by kids control so in the case that you would rather go for that I link his video down in the description well without further introduction let's get started now and let's get started as you might see here we already have some assets and some sins in my project I'll explain them right now first we have a kinematic body to be called model CX I'm gonna make a sprite and a collision shape attached to it as well as a script if we open the script it's mere basics as movement and animations the animations are tied to animate its prey and animated sprite currently has three animations idle [Music] slash and walk right now in our code only walk and idle are being used slash will be explained later because that's pretty much the point of the tutorial and collision shape 2d let me change this real quick coalition shape today is just a collision of our player then we have a test scene that we run it it will just play the critical character which is basic stuff so yeah if your aim for this tutorial I'm guessing that you would have knowledge of how to make basic movement and basic animations with animated sprite so now we're going to add the animation it which is slash for that we're going to go first into project settings input map and we're going to add an action which is going to be called attack we're going to point a key to the action which will be X and when I press the key X my player my character will perform the slash we gotta put that in count now by going into the script and for us I explained in one of my videos earlier for our slash code not to interfere with our other movement scripts we get a a barbel which is going to be cold is attacking and it will be false by default this variable will confirm when the player presses X and we get added to the rest of our code of movement so it doesn't interfere with our attack and vice-versa so if input dot is action pressed right movement x equals speed so here we gotta add another condition which this and is attack equals false now we're going to copa de into the left one and here for the idol one else if movement dot x equals zero if is attacking it was false I'm at sprite will play Idol now we can add our flash so if input is actually just press hi animated sprite play slash and it's attacking equals true now we go whoops here test soon now we go and press X and it performs the animation but we can't move anymore and for them for us being able to move again we get a make it's attacking false again doing such thing is simple we're gonna go into the signals of animates fry and node animation finished we're gonna do as as when the animation of flash finishes it's attacking we'll go back into the so well connect the the signal to the kinematic body and we're gonna write if function on animated sprite animation finish if animation now if unreal sprite animation equals slash is attacking a post boss let's test this now we go we can move right now with press X at finish and we can move again so very simple stuff now we can attack how many times we want and we'll be able to always now that we have the animation we gotta make it work we gotta do some damage so we go into the kinematic body and welding an area to D it will call it will be called attack this attack coalition when they have coalition shape off itself and this attack coalition the coalition shape of the TAC coalition you know what our change is to attack area to make it less confusing the coalition shape of attack area has too much the sword presented within the animators fright animation so we got to the frame this frame looks bigger for us to have an approximate of of the size of the sword this coalition of attack area has to very much not exactly of course that it has to match the the whole sprite that the sword course so this at HACC area obviously won't be activated all the time so we got a present encode just let me we got a link here to is attacking so here we can say function on animated sprite animation finished if animated sprite animation a cross slash attack area coalition shape 2d disabled and when we press attack if input if action just press attack animated sprite dot play / is attacking true and attack area coalition shape 2d disabled [Music] for this going to the debug mode debug mode and to just be able that everyone that everything is to be able to see that everything is working right we're gonna go for this option visible collision shapes so we're going to play this now okay right now the collision seems to be activated no matter what so that means I did something okay I figured out the mistake I use two equal signs instead of one so I apologize about that it was a stupid mistake now if we run this we have the collision active in the beginning we press we press X and it disabled so how do we get rid of this collision to be activated in the beginning that's simple we go to a hack area collision shape and disabled by default so now we run this it's disabled we press X and it will be only activated the time you press X so very simple stuff but even if the equation is activated or not it won't do any damage I'll prove it by creating an enemy right now [Music] now that we have an enemy in our scene you'll notice that if we approach this enemy and press X nothing will happen to it how do we fix that first let's take a look into the code of the enemy so we go to met her and script and you'll see a very basic code with a bar above it's called bad which is false and a line that says if that equals false negative sprite will play either this line of code is pretty explanatory and what we want to do is that our sword in the scene of our main player collides with the enemy so we're gonna take a look to attack area what is attack area important and why did we create a habit area remember attack area holds coalition shape to the coalition for Miss World and our kinematic body has the coalition of the player now we'll create or go into it no no the tab and we'll create a group in attack area that will be cold sore the reason as of why we're creating this group into attack area and not model CX is because since we're adding this group into attack area only attack area will react with an enemy and wait on one model CX or the collision of one of the gangs to react the way the attack area would to put it lightly or to put simply we want a type area to kill the enemy and if we added sword to our main character every time our character touched the enemy the enemy would die when in most video games when you touch an enemy you're the one that is strain the help from so the last thing we're gonna do now is go to our enemies script and where we got a link we're going to go into area signals and use the signal an area and turn will connect it to the enemy and here function in metro area entered area the important reason as of why attack area must be an old of area to be is because then we can use this signal to link both areas the area of the enemy and the area of attack area which is or coalition shape our sword so we can now write if area is in group sword dead will be true animates pride of play destroyed and [Music] we're gonna use another signal for animated sprite this one is optional on animation finish if animals prior animation equals destroyed cue [Music] I favor this one is optional because if you have an animation for the enemy being destroyed then you're gonna use it but if you don't then you just type Q brain here since I have animation I have to use the signal here let's try this now so we're on the scene there's the enemy we press X and it's destroyed so yeah it was pretty simple I'm sorry if I made it really long but I hope it helped and thanks for watching [Music]
Info
Channel: AntiDev, Godot Engine Tutorials & Analysis
Views: 53,497
Rating: undefined out of 5
Keywords: Godot, tutorial, Godot Tutorial, Antidev, Antidev Godot Engine, Mega Man Godot, Tutorial Game Dev, Anti Game Dev, Game Dev, Stop looking at my annotations pls, Rock Man Godot, Mega Man Anti Dev, Godot Engine 3.2, Melee Attacks Godot, Attacks Godot, Attacks Godot Engine, Melee Attacks tutorial
Id: q0WHhsmifkQ
Channel Id: undefined
Length: 17min 12sec (1032 seconds)
Published: Thu Apr 30 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.