How to Code Melee Attacks in Godot: Hitboxes and Hurtboxes

  Рет қаралды 97,269

GDQuest

GDQuest

2 жыл бұрын

Learn to Code from Zero, With Godot: gdquest.mavenseed.com/courses...
---
📚 THE LINKS
Hitbox and hurtbox open-source demo: gdquest.github.io/godot-demos...
---
👥 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: creativecommons.org/licenses/...
You can attribute it to "CC-By 4.0 - GDQuest and contributors - www.gdquest.com/"

Пікірлер: 126
@Chspas
@Chspas 9 ай бұрын
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 9 ай бұрын
i love you.... :P
@FunnyGamerMan
@FunnyGamerMan 6 ай бұрын
very attractive male right here.
@Roninantigo
@Roninantigo 5 ай бұрын
valeu mano 👍
@nicktoonz6861
@nicktoonz6861 5 ай бұрын
Using: self.area_entered.connect(_on_area_entered) works too
@cappuccino32164
@cappuccino32164 3 ай бұрын
you"re a life saver bro
@rayboblio
@rayboblio 2 жыл бұрын
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!
@jtperek9410
@jtperek9410 2 жыл бұрын
This is exactly the tutorial I needed. Excited for the next one!
@astr0cookie269
@astr0cookie269 2 жыл бұрын
this is really great!!! you make the best videos for godot EVER, continue making this vids dude!
@Gdquest
@Gdquest 2 жыл бұрын
Thanks!
@kaishido6698
@kaishido6698 2 жыл бұрын
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 жыл бұрын
Merci :)!
@nitokoshiro5904
@nitokoshiro5904 2 жыл бұрын
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 жыл бұрын
has_method or a version of it totally exists!
@Gdquest
@Gdquest 2 жыл бұрын
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 жыл бұрын
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 жыл бұрын
@@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.
@AcroProjects
@AcroProjects 2 жыл бұрын
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 жыл бұрын
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 Жыл бұрын
@@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 10 ай бұрын
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'.
@TheSolarString
@TheSolarString Жыл бұрын
Is there a C# Equivalent to the class_name keyword, so that the Node will show up in the "Create New Node" window?
@_gamma.
@_gamma. 2 жыл бұрын
That tip about type hinting to filter signal callbacks is so nice! Is that a 4.0 thing?
@Gdquest
@Gdquest 2 жыл бұрын
This is all recorded in Godot 3, you can already use this
@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!
@foxyfoxy9448
@foxyfoxy9448 2 жыл бұрын
Thank you so much! I needed this so bad.
@_gamma.
@_gamma. 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 жыл бұрын
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).
@rashSLG
@rashSLG 2 жыл бұрын
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 жыл бұрын
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 жыл бұрын
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.
@botanictitanium3960
@botanictitanium3960 10 ай бұрын
Hi, GDQuest! Do you have a Godot 4 updated solution for "connect("area_entered", self, "on_area_entered")"?
@421LIZO
@421LIZO 5 ай бұрын
connect("area_entered", self._on_area_entered)
@petarivancevic2162
@petarivancevic2162 9 ай бұрын
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
@zhengistasbolatov8480
@zhengistasbolatov8480 2 жыл бұрын
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 жыл бұрын
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 жыл бұрын
@@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 жыл бұрын
@@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 жыл бұрын
@@puddingface1902 I'd like to see what you got there
@puddingface1902
@puddingface1902 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 kzbin.info/www/bejne/hHS8hpuaYr1nY80 .
@mrkdji6390
@mrkdji6390 2 жыл бұрын
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 жыл бұрын
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)
@JohngoLumpo
@JohngoLumpo 2 жыл бұрын
Amazing leason. Thanks for sharing this.
@thef1rst1
@thef1rst1 2 жыл бұрын
Thank you I needed this
@familiagallego10
@familiagallego10 8 ай бұрын
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 8 ай бұрын
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! :)
@dinsfire8489
@dinsfire8489 2 жыл бұрын
more vids like this pls 😍
@user-nx2gh8oj7z
@user-nx2gh8oj7z Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
how to write it in code
@botanictitanium3960
@botanictitanium3960 10 ай бұрын
Yeah, also want to hear. Anyone figured it out yet?
@junba1810
@junba1810 8 ай бұрын
@@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 :)
@NoRhythm-im2oj
@NoRhythm-im2oj 2 ай бұрын
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?
@G0NI25
@G0NI25 5 ай бұрын
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?
@spindash64
@spindash64 10 ай бұрын
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
@Ralgondo
@Ralgondo 10 ай бұрын
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 6 ай бұрын
Hi gdquest pls can you help me to put ghe hurtbox on the player (every time my player kill my player (mouse = weapon direction) )
@fcktyshawn
@fcktyshawn 2 жыл бұрын
thank you for this tutorial
@teo2805
@teo2805 2 жыл бұрын
New gdquest video? Good day
@Crabble42
@Crabble42 9 ай бұрын
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!
@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.
@thewallofwolfstreet7540
@thewallofwolfstreet7540 Жыл бұрын
but where is the damage variable before we wrote it in the hurtbox and hitbox scripts?
@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?
@ViniCavin
@ViniCavin Жыл бұрын
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 10 ай бұрын
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 10 ай бұрын
@@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 10 ай бұрын
@@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 10 ай бұрын
@@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
@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 жыл бұрын
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.
@7ymke
@7ymke 29 күн бұрын
for some reason collision_layer and collision_mask don't work for me and i have to set them to 1
@timemachine5678
@timemachine5678 22 күн бұрын
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 22 күн бұрын
@@timemachine5678 it now works for me but I don’t know how I did it
@derinasir
@derinasir 2 жыл бұрын
Can you make a video about customising the editor?
@Gdquest
@Gdquest 2 жыл бұрын
We'll get to covering plugins someday, but for now, we have our plate full (unending todolist).
@gruffmadness
@gruffmadness Ай бұрын
links don't seem to work for the resources
@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 жыл бұрын
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.
@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
@YOSFP
@YOSFP 2 жыл бұрын
Why not use signals?
@velsia1
@velsia1 Жыл бұрын
does this also work on 3D ?
@FaceFish9
@FaceFish9 5 ай бұрын
I know i must be dumb for not getting it but when i try to use this code it returns an error for invalid argument that "argument 2 should be Callable"
@FaceFish9
@FaceFish9 5 ай бұрын
nevermind... like i said i was being dumb...
@NexusBaum
@NexusBaum 11 ай бұрын
I'll call my boxes punchbox and ouchbox for clearification :)
@DayOfCasual
@DayOfCasual Ай бұрын
I am unable to find the next video or I am blind?
@valentas000
@valentas000 2 жыл бұрын
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 жыл бұрын
The last lesson of our app Learn GDScript from zero introduces this: gdquest.github.io/learn-gdscript/#course/lesson-28-specifying-types/lesson.tres
@SamuTheFrog
@SamuTheFrog 2 ай бұрын
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 2 ай бұрын
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.
@jeusmarcomascarina4102
@jeusmarcomascarina4102 2 жыл бұрын
I want to make like warcraft
@fiddleriddlediddlediddle
@fiddleriddlediddlediddle Жыл бұрын
Didn't the kickstarter say today's sponsor would be free? Why does it now cost $80?
@Gdquest
@Gdquest Жыл бұрын
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
@beyond-v2j
@beyond-v2j Жыл бұрын
14:39 What ever happened to the next video?
@Gdquest
@Gdquest Жыл бұрын
burnout
@beyond-v2j
@beyond-v2j Жыл бұрын
@@Gdquest that’s understandable
@Gdquest
@Gdquest Жыл бұрын
@@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 Жыл бұрын
@@Gdquest that’s good. Well I’ll be looking forward to seeing it
@Muphet
@Muphet 10 ай бұрын
what is all the debug addon nonsense in the project?
@David_Raab
@David_Raab 9 ай бұрын
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 жыл бұрын
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 жыл бұрын
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.
@nottheoriginalw9237
@nottheoriginalw9237 2 жыл бұрын
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
@memumemu7539
@memumemu7539 Жыл бұрын
@TheSunriseGames
@TheSunriseGames 21 күн бұрын
Bruh, hitboxes have always been to RECEIVE damage, what nonsense are you talking about? Amateur
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 536 М.
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 523 М.
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 168 МЛН
Tutorial: How to create melee attacks using AnimatedSprite! (Godot Engine 3.2)
17:13
AntiDev, Godot Engine Tutorials & Analysis
Рет қаралды 57 М.
A problem so hard even Google relies on Random Chance
12:06
Breaking Taps
Рет қаралды 1,1 МЛН
Do I need a Game Design Document?
5:20
Alchemy Sheep
Рет қаралды 14 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,4 МЛН
Seven Minutes to Decide On Godot 4 in 2024
7:36
GDQuest
Рет қаралды 162 М.
Harder Drive: Hard drives we didn't want or need
36:47
suckerpinch
Рет қаралды 1,6 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 702 М.
Let's Program Doom - Part 1
25:13
3DSage
Рет қаралды 418 М.
How 3D video games do graphics.
3:03:13
Jonathan Blow
Рет қаралды 200 М.
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 168 МЛН