How to Code Melee Attacks in Godot: Hitboxes and Hurtboxes

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ย. 2024
  • Learn to Code from Zero, With Godot: gdquest.mavens...
    ---
    📚 THE LINKS
    Hitbox and hurtbox open-source demo: gdquest.github...
    ---
    👥 CREDITS
    Video edited by Nesi: / nesiawesomeness
    ---
    💌 JOIN US
    Come chat on Discord: / discord
    Follow us on Twitter: / nathangdquest
    ---
    📝 CC-BY LICENSE
    This video is licensed under the CC-By 4.0 license: creativecommon...
    You can attribute it to "CC-By 4.0 - GDQuest and contributors - www.gdquest.com/"

ความคิดเห็น • 134

  • @rayboblio
    @rayboblio 2 ปีที่แล้ว +49

    Wow, there is so much more in this short video than just melee attacks for a Godot noob like myself. This was very informative. Thanks!

  • @Chspas
    @Chspas 10 หลายเดือนก่อน +130

    If anyone is having the error "Invalid argument for "connect()" function: argument 2 should be Callable..."
    I used:
    connect("area_entered", self._on_area_entered)
    Every other piece of code in the video can be copied and it should work smoothly! My other issue was making sure the NPC branch was saved as its own scene so the owner class could register.

    • @aChannel13813
      @aChannel13813 10 หลายเดือนก่อน +5

      i love you.... :P

    • @FunnyGamerMan
      @FunnyGamerMan 7 หลายเดือนก่อน +3

      very attractive male right here.

    • @Roninantigo
      @Roninantigo 6 หลายเดือนก่อน

      valeu mano 👍

    • @nicktoonz6861
      @nicktoonz6861 6 หลายเดือนก่อน +8

      Using: self.area_entered.connect(_on_area_entered) works too

    • @cappuccino32164
      @cappuccino32164 4 หลายเดือนก่อน

      you"re a life saver bro

  • @DimonRgHere
    @DimonRgHere หลายเดือนก่อน +1

    I've watched a lot of videos on this topic and I'm glad I found this one. This is all so useful and convenient than other methods of creating hit and hurt boxes in Godot. Thank you!

  • @astr0cookie269
    @astr0cookie269 2 ปีที่แล้ว +9

    this is really great!!! you make the best videos for godot EVER, continue making this vids dude!

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +3

      Thanks!

  • @kaishido6698
    @kaishido6698 2 ปีที่แล้ว +3

    Merci GDQuest pour les super vidéos, c'est grâce à vous que j'ai pu démarrer ma nouvelle carrière! Lâchez-pas, les gars!

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +2

      Merci :)!

  • @AcroProjects
    @AcroProjects 2 ปีที่แล้ว +17

    This is definitely something I would've appreciated when I made my own hitboxes last year. Very informative for people who may be unfamiliar with Area2Ds and how Godot's collision works. Fantastic job as always!!
    Question though: I don't know if this is out of scoop for your tutorial series, but will you be showing how to have hitbox priority? For example, if I made an attack that has 2 hitboxes (one that is short-ranged but does more damage and one that's further reaching but does less damage) and I wanted the hitbox that does more damage to take priority if both hitboxes hit an object on the same frame.
    I've been looking into that for a while now, but can't really find a consistent way to have hitbox priority. Either way, I look forward to what else you have to show =)

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +21

      It gets a little too specific for the videos we're making now. If you're making a fighting game and need more control (like priority), here's what I'd try:
      1. Instead of catching damage with hurtboxes, apply damage from hitboxes.
      2. When a collision occurs, call get_overlapping_areas() to get all hurtboxes.
      3. If there's more than one, cast a ray to each area you found and apply damage to the closest one.
      It's a simple starting heuristic, which I would test in slow motion with a tool like our debug visualization addon (github.com/GDQuest/godot-visualization-tools, it's not properly documented yet but basically you attach scripts from this addon to nodes to visualize them at runtime like in this tutorial).
      I would then refine the heuristic based on needs. For instance you could use only rectangles for collision shapes and calculate distances between the hitbox and hurtboxes' edges to give priority: the hurtbox you are deepest into takes priority.

    • @shaqalito8740
      @shaqalito8740 ปีที่แล้ว +3

      @@Gdquest Frick what a great question and a great answer! Thank both of you for adding relevant and interesting information to this already interesting video!

  • @AxZelAnimations30
    @AxZelAnimations30 ปีที่แล้ว +4

    I'm transitioning my Unity Project to Godot and conveniently it's very identical to what I did.
    Although I had to use Interface somehow, it seems like it can be done quite easier in Godot (No Interface). I've also been using alot of Tags and Layer Masks back then, while also writting my own way of checking if Team1/Player1 Hitbox collider with Team2/Player2 Hurtbox.
    Thanks for this. I know how to do it but I don't know how to write it as in GDScript. I would assume owner is similar to 'this'.

  • @_gamma.
    @_gamma. 2 ปีที่แล้ว +2

    You should do a separate video on the bitflags for collision and madks. Like, the “bit flag” part of it
    They’re useful for exporting enums as flags too, just kinda hard to wrap your head around

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +2

      It's a bit low on our list of priorities but covering binary numbers... hopefully we'll get to it at some point. We just need some excellent use cases for them (big performance gain, big code simplification... compared to using alternatives).

  • @_gamma.
    @_gamma. 2 ปีที่แล้ว +4

    That tip about type hinting to filter signal callbacks is so nice! Is that a 4.0 thing?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +6

      This is all recorded in Godot 3, you can already use this

  • @artursoares1584
    @artursoares1584 หลายเดือนก่อน

    Great video! Can someone clarify one thing please: you can set the layers and masks in the inspector, so I don't understand why you have to write the layers and masks in the code too.

  • @pragmaticbeaver1555
    @pragmaticbeaver1555 2 ปีที่แล้ว

    Great video with great content, hope to see the follow up video soon! The animation look so satisfying, I would love to learn how to do that!

  • @petarivancevic2162
    @petarivancevic2162 11 หลายเดือนก่อน +1

    Your videos and contributions are amazing! Which tool are you using to create those crisp and beautiful models and animations? Thank you for everything you are doing for the community

  • @mrkdji6390
    @mrkdji6390 2 ปีที่แล้ว +1

    Thank you for the very informative video! Are you planning by any chance to make a video on how to deal with combos?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +4

      Considering it, yes, at least simple combos (not a fighting game with many moves, and moves specific to each character, that you spent months tweaking)

  • @mijkolsmith
    @mijkolsmith 16 วันที่ผ่านมา

    doesn't the hitbox only need a collision mask and the hurt box only a collision layer?

  • @nitokoshiro5904
    @nitokoshiro5904 2 ปีที่แล้ว +33

    All this heavy reliance on strings is so prone to errors. What if a method gets renamed? What if there's a typo? I know they're addressing that in Godot 4 in the case of signals, but seeing that has_method() function still sends a shiver down my spine. Doesn't Godot have any way of referencing the actual method type? In C# it would be something like: owner.HasMethod(typeof(TakeDamage))

    • @teo2805
      @teo2805 2 ปีที่แล้ว +5

      has_method or a version of it totally exists!

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +11

      If you use C# in Godot you can do that. With GDScript in Godot 3 you can't. It's the same kind of duck typing you find in Python. A more robust alternative is what I think I mentioned in the video: emitting a signal that you explicitly connect to from the owner.
      Otherwise, you can use inheritance and type checks. For instance, have an Actor base class that everything that can take damage inherits from. then check if the owner of the hurtbox is of type Actor. In Godot 4 in GDScript, functions are first class so using inheritance, you can directly reference the symbol and get errors in the editor if there's a typo or anything.

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +21

      In practice, is this that prone to errors... not so much if you use the technique sparingly and don't rename functions for things that use this technique. You can also use editor-side warnings, like display a warning if the owner of a hurtbox is lacking the required function (and use an assert at runtime to catch errors in debug builds). That's the kind of thing we do in my team.

    • @nitokoshiro5904
      @nitokoshiro5904 2 ปีที่แล้ว +14

      @@Gdquest Thank you for the thorough reply. For me personally, inheritance and type checks are the way to then. From what I've read on Twitter, Godot core developers are actively reducing the use of strings in GDScript, and I very much welcome that. Once C# is back in Godot4, I might also give that a shot.

    • @hidemat5141
      @hidemat5141 2 ปีที่แล้ว

      I like the editor side warning approach.

  • @mijkolsmith
    @mijkolsmith 16 วันที่ผ่านมา

    could you check make_damage exists directly instead of using a magic string?

  • @zhengistasbolatov8480
    @zhengistasbolatov8480 2 ปีที่แล้ว +5

    What about using groups for hitboxes and if area.is_in_group("group") for hurt boxes? I think this is more effective if you have different types of damage? Also how do you think is it better to disable the CollisionShape, or set Monitoring and Monitorable values in Area2D node?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +3

      Regarding groups, I'd need a concrete example. In my team, we really solve problems in context and teach this mindset, so I can't tell you if using a different approach is better in general: it depends.
      Regarding the areas, either option is fine. Hopefully it makes only a tiny difference performance-wise (if the area's not monitoring or monitorable, it should be skipped during physics frame, and if all its collision shapes are disabled same)

    • @zhengistasbolatov8480
      @zhengistasbolatov8480 2 ปีที่แล้ว +3

      @@Gdquest so I'm making a beat'em up game, which means I'm heavily invested in melee combat, I have light, heavy and some other types of attack. Each type has it's own Area2D and assigned group, it's monitoring controlled via AminationPlayer. As for enemy hurt boxes I have "if area.is_in_group("group")" checks, if the group is "light_attack" they get staggered, and if "heavy_attack" they fall. Also you can have groups like "Fire_damage", "Frost_damage", "Emotional_damage", and assign different values for each type depending on resistances. I am noob at coding and nowhere near as experienced as you are, I just think it's very important to get students familiar with groups.

    • @puddingface1902
      @puddingface1902 2 ปีที่แล้ว +4

      @@zhengistasbolatov8480 I am also making a beat em up game. I used groups but now I also added a script with no methods but variables for things like damage stagger element type. And during attack the player basically transfers all this data to the hitbox's script variables which then the hurtbox accesses when hit.

    • @zhengistasbolatov8480
      @zhengistasbolatov8480 2 ปีที่แล้ว +2

      @@puddingface1902 I'd like to see what you got there

    • @puddingface1902
      @puddingface1902 2 ปีที่แล้ว +2

      @@zhengistasbolatov8480 Thanks. I also have these variables for projectile so they get added to the projectile's script as well. Script for melee hitboxes and projectile. Then the Hurt Box reads on hit. Like Health-=area.damage. Same for stagger though right now I am doing stagger based on damage and remaining health so there's more stagger for low health. This video is an example of the sprites I have made th-cam.com/video/NCYUhd-X4-k/w-d-xo.html .

  • @thef1rst1
    @thef1rst1 2 ปีที่แล้ว

    Thank you I needed this

  • @Mr_Boness
    @Mr_Boness 27 วันที่ผ่านมา

    How do you make the sprites? What app do you use to draw?

  • @dinsfire8489
    @dinsfire8489 2 ปีที่แล้ว +1

    more vids like this pls 😍

  • @spindash64
    @spindash64 11 หลายเดือนก่อน

    In theory, couldn't you just have the "take damage" method and associated parameters+variables in the hurt box? Since you'll typically only need hitpoints on things that you're giving a hurtbox to? I get that this doesn't work as well if you intend to have multiple hurtboxes, but it still seems like a compositional approach might work here

  • @familiagallego10
    @familiagallego10 9 หลายเดือนก่อน +2

    Hello, i'm copying whats being done in the video (asides from changing the call to connect() as someone else stated in the comments) but in the hurtbox script i'm getting the error "error calling from signal "area_entered" to callable "area2d(hurt_box.gd), cannot convert argument 1 from object to object", anyone knows what this means?

    • @junba1810
      @junba1810 9 หลายเดือนก่อน

      I managed to repdroduce your error while working on this myself and here's what I found out. The function takes as an arguement a type MyHitbox. In the video GDQuest mentions that if any other area2d enters the arguement will be null. However that doesn't seem to be the case any more. If ANY other area2d enters the hurtbox, godot says "Woah, I can't convert this Area2D variably to a MyHitbox variable, so you cannot call this function".
      The easiest way to combat this is to have 2 physics layers, 1 for hitbox and 1 for hurtbox. NO OTHER area2ds can exist in these layers or you'll get an error.
      The second way is to change the method and instead of typing _on_area_entered(hitbox: MyHitbox) you need to do _on_area_entered(hitbox: Area2D). That means that the function expects any kind of Area2D. However you will then need to check inside the function if the Area2D that entered is a hitbox or something else.
      So for starters check if any of your other area2ds are entering the hurtbox. if they do then use one of the two ways to solve the issue. Otherwise you can tell me more about the error and maybe I can help. For example send me your code so that I can understand better. Hope this helped! :)

  • @thewallofwolfstreet7540
    @thewallofwolfstreet7540 ปีที่แล้ว

    but where is the damage variable before we wrote it in the hurtbox and hitbox scripts?

  • @fcktyshawn
    @fcktyshawn 2 ปีที่แล้ว

    thank you for this tutorial

  • @NoRhythm-im2oj
    @NoRhythm-im2oj 3 หลายเดือนก่อน

    i just started with godot, in this case this guide is made in godot 3.4.4
    i use godot 4.2 is this still a good practice for hitboxes and hurtboxes to have kinda a plug and play system for weapons and damage values?

  • @CatoNord
    @CatoNord ปีที่แล้ว +2

    Anyone found the way to change the "connect("area_entered", self, "_on_area_entered")" in the hurtbox to work in godot 4?

    • @adrielzzz3148
      @adrielzzz3148 ปีที่แล้ว

      im looking for the same thing, did you find a solution?

    • @artdirectorgiraffe1003
      @artdirectorgiraffe1003 ปีที่แล้ว +4

      I think the syntax in this specific case would be self.area_entered.connect(_on_area_entered),
      self being the node you want to connect, area entered being the specific signal and the name in the parenthesis is the function you are calling. Hope this helps : )

    • @marcdaniellecastro6496
      @marcdaniellecastro6496 ปีที่แล้ว +1

      how to write it in code

    • @botanictitanium3960
      @botanictitanium3960 ปีที่แล้ว

      Yeah, also want to hear. Anyone figured it out yet?

    • @junba1810
      @junba1810 9 หลายเดือนก่อน

      @@botanictitanium3960
      (before I start let me say that I use the words function and method in here but it means the same thing)
      connect in Godot 4 requires two arguements, a Signal and a Callable. A callable is a variable that stores a function that may or may not be associated with an Object (everything in Godot is also an Object if you don't know what the class Object is). In this video connect needs a signal, the object that we want to connect the function to and the name of the function. However, what's convenient for us in Godot 4 is that a callable by definition will (or won't, but in this case will) be associated with an object.
      So to recap. We need 2 things, a signal and a callable. Once way to do this will be to create a varibale of callable type e.g. var myCallable: Callable. This variable will store our function when the node is intialised. So in the _init method we write myCallable = Callable(self, "_on_area_entered"). Then on the _ready method we write connect("area_entered", myCallable) and we are done. This is the same as typing self.connect("area_entered", myCallable). This way of doing this is discouraged by Godot (you can read about it in the Object documentation) and that is because we use too many strings. The compiler cannot understand if a string is "incorrect" because to the compiler a string is just a buch of characters next to each other, it doesn't mean anything to it. That can create problems for us in the future.
      The best (and fastest) way to do this is to write self.area_entered.connect(_on_area_entered). Let's explain a few stuff. Self refers to the node the script is in. Using self we can access the signal, area_entered (notice how area_entered IS NOT a string here, perfect!), lastly from the signal we use the connect method and pass the argument _on_area_entered (this IS NOT a string either!). _on_area_entered is actually a variable of type Callable as we mentioned before since it is a function name. That would be all I think. Hope this helped. For more info read the documentation of Object and Callable :)

  • @teo2805
    @teo2805 2 ปีที่แล้ว

    New gdquest video? Good day

  • @abdooowd
    @abdooowd 2 ปีที่แล้ว

    Could you please mqke a tutorial about how to optimize a 3d game? Like if the player is far away from from those objects then they donnt get loaded or just disappear.
    It would really help.

  • @DayOfCasual
    @DayOfCasual 3 หลายเดือนก่อน +2

    I am unable to find the next video or I am blind?

  • @Ralgondo
    @Ralgondo ปีที่แล้ว

    I get errors when I run the disable and enable for collision shapes in the animation player, not with a simple setup like this, but when i use it with a more complex situation. Requires me to use set_deferred, I wish it was built in somehow

  • @Slifer.GameDev
    @Slifer.GameDev 8 หลายเดือนก่อน

    Hi gdquest pls can you help me to put ghe hurtbox on the player (every time my player kill my player (mouse = weapon direction) )

  • @gruffmadness
    @gruffmadness 3 หลายเดือนก่อน

    links don't seem to work for the resources

  • @7ymke
    @7ymke 2 หลายเดือนก่อน

    for some reason collision_layer and collision_mask don't work for me and i have to set them to 1

    • @timemachine5678
      @timemachine5678 2 หลายเดือนก่อน

      Same on my end, setting them in the script didn't do anything for me and both Layer and mask are set to 1 on creation

    • @7ymke
      @7ymke 2 หลายเดือนก่อน

      @@timemachine5678 it now works for me but I don’t know how I did it

  • @ViniCavin
    @ViniCavin ปีที่แล้ว +1

    What's your approach when a Hitbox that belongs to the Player (sword) touch it's Hurtbox? I'm trying to find a solution for that but I assume it's a common issue, since most enemies have hitboxes and hurtboxes on them.

    • @rdoee3558
      @rdoee3558 ปีที่แล้ว

      Pretty late but could you make a hurtbox and hitbox associated to the player and P1_hitbox will check for the P1_hurtbox and if its the case it'll ignore the hurtbox

    • @ariosthemak
      @ariosthemak ปีที่แล้ว

      Also late, but figuring out a similar thing - for me the way right now is to check for owner. If it's the same instance, ignore collision.
      The other way (depending on your game) might be differentiating by layers, although that can get a bit hard to track at times.

    • @WebCamCartmell
      @WebCamCartmell 11 หลายเดือนก่อน

      @@ariosthemak how are you checking for the owner in this example? everything i'm trying isn't working like if hitbox == owner/self etc

    • @ariosthemak
      @ariosthemak 11 หลายเดือนก่อน

      @@WebCamCartmell I'm checking for self.owner == area.owner . If true -> return (with a debug print). Not 100% sure on the solution, but seems to be working for my needs at least

    • @WebCamCartmell
      @WebCamCartmell 11 หลายเดือนก่อน

      @@ariosthemak omg THANK YOU. i've been wracking my brain the last two nights trying to sus it out haha!
      for anyone in the future, in the hurtbox script add the following under "func _on_area_entered(hitbox: HitBox):" add the following:
      if self.owner == hitbox.owner:
      return

  • @YOSFP
    @YOSFP 2 ปีที่แล้ว

    Why not use signals?

  • @NexusBaum
    @NexusBaum ปีที่แล้ว

    I'll call my boxes punchbox and ouchbox for clearification :)

  • @katekko1
    @katekko1 2 ปีที่แล้ว

    The courses is so expensive here to my country, would be nice if the price was adjusted based on the country :/

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +2

      It does but on the platform we use, it's only at checkout, you get a coupon code. We're coding a new platform where prices are adapted to the user from the start.

  • @derinasir
    @derinasir 2 ปีที่แล้ว

    Can you make a video about customising the editor?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +1

      We'll get to covering plugins someday, but for now, we have our plate full (unending todolist).

  • @velsia1
    @velsia1 ปีที่แล้ว

    does this also work on 3D ?

  • @Soul-tc4cj
    @Soul-tc4cj 2 ปีที่แล้ว

    Can you explain context context based steering?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว

      I'm sorry but I don't know what that is.

    • @Soul-tc4cj
      @Soul-tc4cj 2 ปีที่แล้ว

      @@Gdquest kidscancode has a video on it i couldn't understand

  • @valentas000
    @valentas000 2 ปีที่แล้ว +1

    my god... I never used such things as
    " -> void: "
    is there is a tutorial ?

    • @BrunodeSouzaLino
      @BrunodeSouzaLino 2 ปีที่แล้ว

      This is a type hint and it's more meant to aid the programmer than anything code related. Void simply means the function is supposed to not return anything.

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +2

      The last lesson of our app Learn GDScript from zero introduces this: gdquest.github.io/learn-gdscript/#course/lesson-28-specifying-types/lesson.tres

  • @Muphet
    @Muphet 11 หลายเดือนก่อน

    what is all the debug addon nonsense in the project?

  • @jeusmarcomascarina4102
    @jeusmarcomascarina4102 2 ปีที่แล้ว

    I want to make like warcraft

  • @David_Raab
    @David_Raab 10 หลายเดือนก่อน

    Good video. But ...
    Hurtboxes are the ones getting hit, and hitboxes do hurt ... Got it!

  • @jasonfanclub4267
    @jasonfanclub4267 2 ปีที่แล้ว

    😍😍😍😍

  • @BrunodeSouzaLino
    @BrunodeSouzaLino 2 ปีที่แล้ว

    Isn't there a more Godot like way of doing that than attempting to hack a ECS mechanic into a node based engine? There are too many moving parts and a lot can go wrong in there.

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +1

      It's simple composition, it's not like or trying to be like an ECS. Where do you see many moving parts? And what is it you think can go wrong? The duck-typing and owner.take_damage() call?

    • @BrunodeSouzaLino
      @BrunodeSouzaLino 2 ปีที่แล้ว

      @@Gdquest As someone already commented, this way requires the script to know too much about the object it's interacting with. Simple typos and small things done out of order can break the system and you'd have no way of knowing precisely where it went wrong, as Godot doesn't have a helpful debugger (you can't pin variables for monitoring, for example) and some of the error messages are ambiguous.

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +2

      It's a principle-based problem you're raising here. The other comment I recall raising an issue was very concrete: the reliance on strings throughout gdscript is more error-prone than using symbols, which is true. But it's a limitation we work with in Godot 3. As I mentioned in the other thread, a possible solution is to add asserts to guard against issues and get precise error messages.
      Why shouldn't a hurtbox use duck-typing to call a function on its host?
      You can avoid that and add a layer of indirection through a signal, but you'll need more code in your project, thus create more surface area for bugs: you'll need each entity to find its hurtbox and connect to it. You'll also still have a dependency: if the connection doesn't happen reliably, hits won't work.
      One thing you can do is remove the condition on the hurtbox: if the take_damage() function isn't properly defined, you'll get a clear error and stack trace.
      I would recommend trying both approaches very seriously, forgetting about principles. Like, looking at the problems and solutions very concretely, in practice. Which saves you more development time or code? What bugs do you *actually* get during production? How can you avoid those?
      I'm not saying what's shown in the video is *the* right way to go. Like all programming, it's one option that'll work great in some contexts. I'd use this in some projects and approach things differently in others. Depends on the requirements and the exact problem at hand.
      But a node knowing about the context it's in is never the problem in itself. The problem is much more concrete than that.

  • @TheSunriseGames
    @TheSunriseGames 2 หลายเดือนก่อน

    Bruh, hitboxes have always been to RECEIVE damage, what nonsense are you talking about? Amateur

  • @jtperek9410
    @jtperek9410 2 ปีที่แล้ว +11

    This is exactly the tutorial I needed. Excited for the next one!

  • @TheSolarString
    @TheSolarString ปีที่แล้ว +3

    Is there a C# Equivalent to the class_name keyword, so that the Node will show up in the "Create New Node" window?

  • @botanictitanium3960
    @botanictitanium3960 ปีที่แล้ว +3

    Hi, GDQuest! Do you have a Godot 4 updated solution for "connect("area_entered", self, "on_area_entered")"?

    • @421LIZO
      @421LIZO 7 หลายเดือนก่อน +1

      connect("area_entered", self._on_area_entered)

  • @rashSLG
    @rashSLG 2 ปีที่แล้ว +4

    Super awesome to see that Godot lets you make your own nodes based on your needs. Very cool!
    Question to anyone willing to answer, say I'm making multiple attacks (not a combo, but like multiple attacks on different buttons), would I need to make the hitbox and then disable/enable each one per attack, or would I be able to instance new ones in code (and sometimes delete them) as needed?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +3

      Adding the option to toggle hit boxes enabled would be a good feature, and I would use that to give multiple hitboxes to a given weapon if needed. You can always instance nodes at run time but assuming that you want to edit the shapes in the editor and keep both the shape and damage amount fixed for a given hitbox I would rather disable them. Instancing and setting them up from code may not be as productive unless you build other tools to edit hitboxes interactively.

    • @puddingface1902
      @puddingface1902 2 ปีที่แล้ว +2

      In my game I use the same hitboxes for slashing and stabbing for eg. but you can use the hurtbox area entered to detect what kind of attack. Either you can use area.get_parent().attack_type or whatever variable you use. And do damage calc based on that. Or you can put a(the same) script on all hitboxes and through your character's main script add damage value to your hitbox's script. Which will then be read by the hurtbox during area entered signal.

  • @justin32149
    @justin32149 2 ชั่วโมงที่ผ่านมา

    What version of godot is it?

  • @RedhanabiRed-hanabi
    @RedhanabiRed-hanabi 10 วันที่ผ่านมา

    where can i find the previous video? my sword doesn't move XD ...

  • @nottheoriginalw9237
    @nottheoriginalw9237 2 ปีที่แล้ว +1

    anybody's, pls rember that! i wish all of you the best in your future endeavours and hope tNice tutorials year will treat us better

  • @fiddleriddlediddlediddle
    @fiddleriddlediddlediddle 2 ปีที่แล้ว +1

    Didn't the kickstarter say today's sponsor would be free? Why does it now cost $80?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว

      No, we pledged to make one free and open-source app, Learn GDScript From Zero ( github.com/GDQuest/learn-gdscript ), and one paid course, Learn to Code With Godot, which is the product that sponsored the creation of the app and all the free demos, contributions to Godot, etc. in 2022

  • @SamuTheFrog
    @SamuTheFrog 3 หลายเดือนก่อน

    Minor correction @4:00
    Uhm
    Binary numbers are 1s and 0s, 2 is not a binary, it is an integer, but not a binary.
    I maybe wrong but im like 99% certain binary means two variants/values.
    In this case, two integers, 1 or 0.
    GET IT RITE PUNK

    • @Gdquest
      @Gdquest  3 หลายเดือนก่อน

      Binary is the base in which you represent the numbers. You can represent any number in binary form, with a series of zeros and ones. In base 10, which we most often use to represent numbers, you have 10 digits instead of only two.
      If you write the number two in code technically, yes, it's an integer or a float in gdscript. But if you use a bitwise operator, it will use binary operations and the binary representation of the number to apply the operation. In memory, all numbers exist in binary form, and it's the representation you want to have in mind in this case.

  • @foxyfoxy9448
    @foxyfoxy9448 2 ปีที่แล้ว +1

    Thank you so much! I needed this so bad.

  • @G0NI25
    @G0NI25 7 หลายเดือนก่อน

    Hey GDQuest I have question regarding the hurtboxes. What if, for example I wanted to have three collission boxes in three different areas, and have them react depending on the type of attack, how would I be able to code something like that?

  • @mistery8363
    @mistery8363 ปีที่แล้ว

    is it necessary to create new scripts? wouldn't it be enough to assign a layer/mask to hitboxes, another with hurtboxes but always using collisionshape2d?

  • @beyond-v2j
    @beyond-v2j 2 ปีที่แล้ว +1

    14:39 What ever happened to the next video?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว

      burnout

    • @beyond-v2j
      @beyond-v2j 2 ปีที่แล้ว

      @@Gdquest that’s understandable

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +1

      @@beyond-v2j I'm getting back on my feet now so I'll do my best to make this one soon though! :)

    • @beyond-v2j
      @beyond-v2j 2 ปีที่แล้ว

      @@Gdquest that’s good. Well I’ll be looking forward to seeing it

  • @JohngoLumpo
    @JohngoLumpo 2 ปีที่แล้ว

    Amazing leason. Thanks for sharing this.

  • @willyjoe7487
    @willyjoe7487 2 ปีที่แล้ว

    Could you also use this system for non-melee attacks, like arrows, or is there a better way to do those?

    • @Gdquest
      @Gdquest  2 ปีที่แล้ว +2

      You can absolutely use this for ranged attacks. Just, depending on the speed of projectiles, sometimes you need to add a raycast on top of the hurtbox. Especially if projectiles move fast (because they could skip past an enemy in one frame). Typically in fast-paced shooters you have this problem.

  • @memumemu7539
    @memumemu7539 ปีที่แล้ว

  • @Crabble42
    @Crabble42 11 หลายเดือนก่อน

    Whoa, I really like the concept of "if owner.has.method". I never thought about handling things that way. That's really cool and useful!