HitBox2D - cluttered-code/godot-health-hitbox-hurtbox GitHub Wiki
inherits: Area2D
Detects HurtBox2D components to automatically apply damage or healing.
Description
Detects HurtBox2D components to automatically apply damage or healing. Can also detect collisions with other HitBox2D
components.
hurt_box_entered and hit_box_entered signals are provided to enable the User to create more complex interactions.
[!CAUTION]
ignore_collisions = true
should be set when callingqueue_free()
to avoid collisions with other components.
[!warning] The
Collison Mask
needs to be set so HurtBox2D and HitBox2D collisions can be detect.Collision Layer
is optional. It needs to be set to enable collision detection by HitScan2D and other HitBox2D components.
Tutorials
Properties
type | name | default |
---|---|---|
Health.Action | action | DAMAGE |
int | amount | 1 |
bool | ignore_collisions | false |
Signals
hit_box_entered
signal hit_box_entered(hit_box: HitBox2D)
Emitted when colliding with another HitBox2d
. Useful for interactions between projectiles and melee weapons.
- hit_box is the other
HitBox2D
being collided with.
hurt_box_entered
signal hurt_box_entered(hurt_box: HurtBox2D)
Emitted when colliding with a HurtBox2D. Will apply DAMAGE
or HEAL
to HurtBox2D after emitting.
- hurt_box is the HurtBox2D being collided with.
action_applied
signal action_applied(hurt_box: HurtBox2D)
Emitted after DAMAGE
or HEAL
is applied to HurtBox2D.
- hurt_box is the HurtBox2D the action was applied to.
unknown_area_entered
signal unknown_area_entered(area: Area2D)
Emitted when colliding with an Area2D
that isn't a HurtBox2D or another HitBox2D
.
- area is the
Area2D
being collided with.
Property Descriptions
action
@export var action: Health.Action = Health.Action.DAMAGE
The Health.Action to perfrom on the affected Health component.
amount
@export var amount: int = 1
The amount of the Health.Action to perfrom on the affected Health component.
ignore_collisions
@export var ignore_collisions: bool = false
The Health.Action to perfrom on the affected Health component.