How to make a melee attack, such as a sword swing or punch. Art by Elthen: elthen.itch.io/ Text version: godotrecipes.co... Support me on Patreon: / kidscancode
My animation was refusing to play all the way even when I had the playtime longer than the animation. This tutorial fixed everything and now my character is looking spicy
thanks all the other videos i tried to watch on this made the whole process really complicated, when i just needed to make area2s a child of the sprite. i really appreciate this vide.
I know this is an old tutorial now. But, just watched it now. It isn't that useful without an explanation of how to put the Group together to make it work. I tried all the suggestions in the comments, and none of them worked. That said, I still appreciate taking the time to make this tutorial.
those sprites look pretty damn good I must say, thank you for your work good sir, I've been following you since the python days. I wouldn't say your content is really for young children but as a 30 year old dude I enjoy it.
This would've been really useful when I was coding that - I think I ended up doing something like making a fireball and setting the velocity to zero then animating a sword instead
Everything has been super helpful, but I can't figure out how to set up the hurtbox on the enemy's node to talk with the player node. Can anybody help me?
I got something like this working, there's one huge oversight that this video didn't mention for the latest version of Godot. Using -1 on the Animated Sprite scale does NOT flip the hurtbox horizontally. Neither does flip_h on the Sprite node. As far as I can see, you have to make a hurtbox for the left and right facing attacks, running a check to see of the Animated Sprite is flipped and enabling the corresponding hurtbox . Everything else is spot on, just baffled but taking this hacky shortcut that no longer works in Godot 3.1.
@@Kidscancode Whoops, I used a Node instead of a Node 2D and didn't realize that Nodes don't have transform information, but Node 2Ds do. I think that should be mentioned in this video.
In case animation and movesets are far more complex than in this case, would it be advisable to have the whole animation part be handled by a different scene that receives input from the player through the character scene?
i do have one issue with this setup, with characters that do melee damage with a weapon, you can't just flip or scale -1 them, you need a different animation for them to keep using the same hand, i know a lot don't care about this, but i do, it's some extra work, and it's even worth it even though 9/10 don't see it or at least call it out, but i bet you that 5/10 will call it out if you don't care about this
I got stuck on trying to get the Area2D's collision box to flip when the character turns around. I was already using flip_h on my character's sprite in my movement script (I'm using a different method than yours here), but my hitbox won't flip even though my sprite does. So how can I easily get it to flip without redoing my whole movement code?
I think you'll have to change scale through code. You don't have to re-write your entire code, you only have to add new lines where your character movement is. I'm also stuck on a problem like yours.
I found a way to fix it! The code is: $Sprite.scale.x = -1 ( if your character is moving to the left) and $Sprite.x = 1 (if your character is moving to the right) Try to add that to your script
Emaleth very true, however the animation player adds the convenience of seeing exactly when something will occur in an animation and being able to easily edit it for new animations aswell. I used to use the timer method myself and I hate myself for it now because this is so much easier XD
@@minebrostj1430 yes, but if you like me have already player done and then you want to add melee, well... for me at least, as a beginner, it was simpler.
Thank you for your tutorials. I wasn't able to find information about "advanced condition" in state machine transition. Is there any way I can do that?
Hello, I need help. Could you help me to put an enemy character which I can attack and he will die ? I could not do it. I created my character but I could not set collasion.
Thanks, I watched your video and I see that you implement an AnimationPlayed and a basic Sprite, I ask you, how could I do the same using an AnimatedSprite? I already have several animations that way, but I can't find a way to integrate what you do with what I have.
You can't do this with AnimatedSprite. The AnimationTree state machine works by controlling AnimationPlayer nodes. AnimatedSprite is not very sophisticated - it's a much simpler form of animation.
@@Kidscancode I solved my problem; getting variables from the said area 2D since the damage dealing function is interacting with the area 2D; I found a way to pass the info to the main body of the player.
That is how the `area_entered` signal is supposed to work. If you want to continuously check, use a variable to keep track of the body when it enters, and then reset that variable when it leaves.
I don't know how you did it. There was no collision trigger on my version (3.1.1), so I submitted a bug. If you can provide a Godot project demo, I'll see if I missed anything. github.com/godotengine/godot/issues/28803