Hurtboxes, Hitboxes and debuffs

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By shishyando

Hello everyone, I’m trying to make a hurtbox scene to reuse it on each enemy type I make. The problem is that on different weapons (Hitboxes) I define different arrays of debuffs and I want to make such hurtbox that will consider all the debuffs and send them to a particular enemy type. For example I have a sword with bleeding effect and a bow with stun effect. I want to make a single hurtbox that will consider these two possible debuffs and send them to an enemy this hurtbox belongs. I don’t want to write the same code for each enemy. I’m really sorry if I’m asking stupid questions, I’m new to Godot and I’m trying some new stuff. I will be very glad if you could help me out <3

:bust_in_silhouette: Reply From: Arandual

You could write all these effects into your hitbox.
And then upon actually assigning this hitbox to a weapon/enemy you could set the effects you want to true, or a value where 0 would mean the effect doesn’t get applied.

You could then access members of the hitbox in the hurtbox by using signals.
You can connect to signals using the node inspector in the right of the editor.

If you do it right you create a get a method added to your hurtbox script called something like func _on_HurtBox_area_entered(area): or func _on_HurtBox_body_entered(body):

You can then acces your array via the area or body parameter for example: area.yourArray

You could even handle all this outside the hurtbox and only have it as a simple collision detector.

If this is a but vague or much there is also a video online that thought me most of what you’d need to know to set something like this up, here is the link: