+2 votes

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

in Engine by (19 points)

1 Answer

+1 vote
Best answer

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:
https://youtu.be/vDbEfmPcv-Q

by (48 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.