mj177/demo/agents/scripts/hurtbox.gd
2025-02-01 22:51:01 +01:00

22 lines
731 B
GDScript

#*
#* hurtbox.gd
#* =============================================================================
#* Copyright (c) 2023-present Serhii Snitsaruk and the LimboAI contributors.
#*
#* Use of this source code is governed by an MIT-style
#* license that can be found in the LICENSE file or at
#* https://opensource.org/licenses/MIT.
#* =============================================================================
#*
class_name Hurtbox
extends Area2D
## Area that registers damage.
@export var health: Health
var last_attack_vector: Vector2
func take_damage(amount: float, knockback: Vector2, source: Hitbox) -> void:
last_attack_vector = owner.global_position - source.owner.global_position
health.take_damage(amount, knockback)