Godot Recipes: Melee Attack

Поділитися
Вставка
  • Опубліковано 22 тра 2019
  • How to make a melee attack, such as a sword swing or punch.
    Art by Elthen: elthen.itch.io/
    Text version: godotrecipes.com/3.x/animation...
    Support me on Patreon: / kidscancode

КОМЕНТАРІ • 96

  • @grandromusic683
    @grandromusic683 5 років тому +133

    4 Seconds in and he already faces you with your biggest problems...
    10/10 Straight forward

    • @bevvy.bee9
      @bevvy.bee9 4 роки тому +3

      I absolutely love that

  • @ccgb92
    @ccgb92 5 років тому +12

    Good lord, the power of the AnimationPlayer. It's simply amazing

  • @cengizoner9613
    @cengizoner9613 5 років тому +2

    Keep up the great work, Chris! The Godot community is lucky to have you!

  • @sherlockrobin597
    @sherlockrobin597 5 місяців тому

    I've been grappling with this for two days and you solved it in 5 minutes and 18 seconds. Thanks!

  • @soundrogue4472
    @soundrogue4472 9 місяців тому +3

    You are a life saver for showing the actual collision shapes! I just realized my coding issue!

  • @KruzSanchez
    @KruzSanchez 4 роки тому +16

    Can you show us the code for the hurtbox and how to set that up?

  • @xzeeno3712
    @xzeeno3712 2 роки тому +4

    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

  • @gustavomuller455
    @gustavomuller455 4 роки тому +9

    Thank you so much, this is the type of tutorials that UA-cam needs.

  • @vast3394
    @vast3394 16 днів тому

    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.

  • @andrewjhec1623
    @andrewjhec1623 5 років тому +20

    Your godot tutorial videos are the literal best. I appreciate your work so much. Thank you!

  • @sickle7291
    @sickle7291 3 роки тому +1

    Good tutorial with good content in only 5 minutes. I really enjoy this tutorial thank you.

  • @EruRoraitoX
    @EruRoraitoX 3 роки тому

    Thanks for quick and clean tutorials

  • @lowpolygon
    @lowpolygon 5 років тому

    This answered a lot of my question,thanks

  • @llk3892
    @llk3892 5 років тому +1

    I vastly underestimated the power of animation player when I first started using Godot... wish I had this video back then

  • @sakealex
    @sakealex 5 років тому +11

    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.

  • @mikhail6729
    @mikhail6729 5 років тому

    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?

  • @drakibble2199
    @drakibble2199 5 років тому +1

    Wow, I wish I knew about this before I started my attack code. Thanks for the tutorial!

  • @BlazeXth
    @BlazeXth 4 роки тому +3

    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?

  • @frankovacs4865
    @frankovacs4865 5 років тому

    cool idea, waiting for more recipes!

    • @Kidscancode
      @Kidscancode  5 років тому

      I've already added more on the site, just haven't had a chance to record them yet!

  • @Comakino
    @Comakino 5 років тому +2

    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

  • @CASMANWHAT
    @CASMANWHAT 3 роки тому

    this channel is a god send! thank you!

    • @CASMANWHAT
      @CASMANWHAT 3 роки тому

      ps. some requests i have for tutorials - a dialogue system and a turn based rpg :)

    • @Kidscancode
      @Kidscancode  3 роки тому

      GDQuest has both of those! ua-cam.com/channels/xboW7x0jZqFdvMdCFKTMsQ.html

  • @woogee513
    @woogee513 Рік тому +1

    could we possibly get these updated to the newest versions?

  • @NocturnalMorning
    @NocturnalMorning 2 роки тому +1

    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.

  • @DrJoe-sm9no
    @DrJoe-sm9no 3 роки тому +1

    so what would the code for the barrel be- how do the barrel register that it has been hurt?

  • @darkfalconage679
    @darkfalconage679 4 роки тому +1

    How did you made the dummy (barrel)?

  • @andremoraes7067
    @andremoraes7067 5 років тому +1

    hey man! thanks for all of your work

    • @Kidscancode
      @Kidscancode  5 років тому +2

      ua-cam.com/play/PLsk-HSGFjnaFOLHUcZFHD988Wg39rkopw.html
      ua-cam.com/play/PLsk-HSGFjnaFwmOFrfD4gQQqvgvEUielY.html

  • @faikyesilyaprak8761
    @faikyesilyaprak8761 4 роки тому

    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.

  • @RND-vq3bb
    @RND-vq3bb Рік тому +1

    How to make hurt box?

  • @marciopaulo1708
    @marciopaulo1708 Рік тому

    How to do with the character's weapon separate?

  • @Tesla7
    @Tesla7 4 роки тому

    how do we get the sprite into the animationplayer?

  • @dirtyratfinkbastard
    @dirtyratfinkbastard 4 роки тому +6

    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?

    • @daniperez4195
      @daniperez4195 4 роки тому

      the wat to do it is putting the "hurtbox" tag on the area2D (that is parent) of the collishion shape you want to detect

  • @ShuuiTun
    @ShuuiTun 3 роки тому +3

    How can I do it for the opposite side? :(

    • @agussetulain5056
      @agussetulain5056 3 роки тому +2

      I have the same problem :( Can you solve it?

  • @TitlePending
    @TitlePending 5 років тому +5

    Can you do how to do a fighter game next or at some point? Also, looking forward to new recipes.

  • @luislodosm
    @luislodosm 4 роки тому

    Very nice and simple

  • @herc34es
    @herc34es 2 роки тому

    This doesn't seem to work with the animatedSprite note; right? I was trying but could not figure it out....

  • @anixma12
    @anixma12 4 роки тому

    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.

    • @Kidscancode
      @Kidscancode  4 роки тому +1

      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.

  • @daniel-zh9nj6yn6y
    @daniel-zh9nj6yn6y 4 роки тому +4

    Put some ads on your videos, I'll gladly watch them. I can't support anyone on Patreon right now.

  • @mechap7612
    @mechap7612 5 років тому

    Thank you so much

  • @tohut6307
    @tohut6307 3 роки тому

    Can somebody help me when I run and start attacking it says "nonexistent function in _group in base Area2D ?

    • @Kidscancode
      @Kidscancode  3 роки тому

      The function name is "is_in_group()"

  • @pattyorigami
    @pattyorigami 4 роки тому +1

    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?

    • @aZaamBie135
      @aZaamBie135 4 роки тому +1

      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.

    • @aZaamBie135
      @aZaamBie135 4 роки тому +1

      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

  • @lemongummy7047
    @lemongummy7047 4 роки тому

    I'm having trouble to do it in 3d :( guess I'll go back to 2d..

  • @osloyy
    @osloyy 4 роки тому

    how do you do this with the AnimatedSprite node?

    • @Kidscancode
      @Kidscancode  4 роки тому

      You couldn't use this technique with AnimatedSprite, as it only controls the displayed texture. AnimationPlayer is capable of much more than that.

  • @gargoyled_drake
    @gargoyled_drake 2 роки тому

    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

  • @trepaning
    @trepaning 5 років тому

    excellent.

  • @MindChamber
    @MindChamber 3 роки тому

    great tutorial..

  • @adhityarisyad9029
    @adhityarisyad9029 4 роки тому +2

    oh lord im so stupid, ive been using timer to match my animation with the collision shape hide/show when it could be so much easier. i hate myself

    • @ZunaZurugi
      @ZunaZurugi 4 роки тому +2

      Well the worst part about learning an game engine and programming are all those possibilitys you didnt even think of :D

  • @tonywithani
    @tonywithani 4 роки тому

    I enjoy your tutorials. They are extremely helpful. Are there sample file available for the project on github?

    • @Kidscancode
      @Kidscancode  4 роки тому

      Not really, as this was a mishmash of a project that I made to demonstrate a few different things.

    • @tonywithani
      @tonywithani 4 роки тому

      @@Kidscancode Thank you for replying

  • @hollowvoide6567
    @hollowvoide6567 2 роки тому

    how do you do it with 3d?

    • @Kidscancode
      @Kidscancode  2 роки тому

      In pretty much the same way. Use Area instead of Area2D, etc.

  • @commentingexistentialcrisi9564
    @commentingexistentialcrisi9564 4 роки тому

    I have a problem with using signals, the problem is that they only emit the signal once they enter an area and not while in the area. Any solutions?

    • @Kidscancode
      @Kidscancode  4 роки тому

      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.

    • @commentingexistentialcrisi9564
      @commentingexistentialcrisi9564 4 роки тому

      @@Kidscancode oh thanks

  • @redandblack641
    @redandblack641 4 роки тому

    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
      @Kidscancode  4 роки тому +1

      This demo was made in Godot 3.1. Scaling any Node2D will also affect its children.

    • @redandblack641
      @redandblack641 4 роки тому

      @@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.

  • @Khusyasy
    @Khusyasy 3 роки тому

    very helpfull, thanks

  • @giuseppefontana5471
    @giuseppefontana5471 4 роки тому

    can we use the same technique with AnimatedSprite?

    • @Kidscancode
      @Kidscancode  4 роки тому

      AnimatedSprite can't enable/disable the collision shape.

    • @giuseppefontana5471
      @giuseppefontana5471 4 роки тому

      @@Kidscancode thank you for the quick reply. I'll try with AnimationPlayer

  • @IgorogI1000
    @IgorogI1000 4 роки тому

    Great!

  • @emaleth6518
    @emaleth6518 5 років тому

    Similar thing can be done without animationplayer. You just need timer to set for how long area2d should be active :)

    • @minebrostj1430
      @minebrostj1430 5 років тому +3

      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

    • @emaleth6518
      @emaleth6518 5 років тому

      @@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.

    • @minebrostj1430
      @minebrostj1430 5 років тому

      @@emaleth6518 yeah I agree, that's why I used timers in the first place, I'm working on transferring it all to the animation player now.

  • @hunterrayz5407
    @hunterrayz5407 4 роки тому

    I might be making myself look stupid but uhhh......... how did you make the hurtbox?

  • @sohaslyn612
    @sohaslyn612 2 роки тому

    wow i wonder why you didnt get million sub

  • @soundrogue4472
    @soundrogue4472 9 місяців тому

    Maybe I missed something but did you have a script in the area2D or something? It's not exactly working.

    • @Kidscancode
      @Kidscancode  9 місяців тому

      Yes, you can see it in the written version: kidscancode.org/godot_recipes/3.x/animation/melee_attacks/

    • @soundrogue4472
      @soundrogue4472 9 місяців тому

      @@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.

  • @Anonymous-jo2no
    @Anonymous-jo2no 5 років тому +3

    Umm... WTF is group?

    • @daniel-zh9nj6yn6y
      @daniel-zh9nj6yn6y 4 роки тому

      I think it's a category of objects that can be hurt (enemies) or destroyed (barrels, treasure chests).

  • @ayrton_x2447
    @ayrton_x2447 2 місяці тому

    In godot 4 please :D

  • @codelazy2855
    @codelazy2855 5 років тому

    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

  • @w4yzet
    @w4yzet 3 роки тому

    спс

  • @viniguerrero
    @viniguerrero 5 років тому +1

    Awesome video! Best explanation possible for a real time game ;) Keep it up #VaiBrasil

  • @potatopen5282
    @potatopen5282 4 роки тому

    Can you make a gun tutorial? Something like enter the gungeon, but with Godot. There are no good tutorials on guns, would love it if you made one!

    • @Kidscancode
      @Kidscancode  4 роки тому +1

      There are lots of good tutorials on creating different kinds of projectiles. See the official godot-demos, GDQuest, GameEndeavor, etc.

  • @poisonicecream4916
    @poisonicecream4916 3 роки тому

    Hmmm