HitScan2D - cluttered-code/godot-health-hitbox-hurtbox GitHub Wiki
inherits: RayCast2D
Detects HurtBox2D components to automatically apply damage or healing.
Description
Detects HurtBox2D components to automatically apply damage or healing. Can also detect collisions with HitBox2D components.
hurt_box_entered, hit_box_entered, and action_applied signals are provided to enable complex interactions.
[!warning] The
Collison Mask
needs to be set so HurtBox2D and HitBox2D collisions can be detect.
[!warning] Collisions with HitBox2D are asymmetric, they can only be detected from
HitScan2D
. Interactions will have to be initiated from this component.
Tutorials
Properties
type | name | default |
---|---|---|
Health.Action | action | DAMAGE |
int | amount | 1 |
Signals
hit_box_entered
signal hit_box_entered(hit_box: HitBox2D)
Emitted when colliding with a HitBox2D. Useful for interactions between projectiles.
- 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.
Method Descriptions
fire
func fire() -> void
Performs get_collider()
to determine if any HurtBox2D or HitBox2D components are being collied with. Appropriate signals will be sent and DAMAGE
or HEAL
applied to HurtBox2D.