add health component and FollowTarget Enemy Controller and minor changes

This commit is contained in:
2026-05-20 19:31:29 +01:00
parent bceb6c6df8
commit 962bc016a3
9 changed files with 56 additions and 5 deletions
+25
View File
@@ -0,0 +1,25 @@
class_name HealthComponent extends Node
@export var max_health:float = 100
var _health = 100
signal health_changed(current_health:float)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
_health = max_health
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
pass
func add_health(amount:float):
_health = max(_health + amount, max_health)
health_changed.emit(_health)
func subtract_health(amount:float):
_health = max(_health - amount, 0)
health_changed.emit(_health)
func get_health() -> float:
return _health
+1
View File
@@ -0,0 +1 @@
uid://o21d85vy2cfs
+1 -2
View File
@@ -1,11 +1,10 @@
class_name HitBox extends Area2D
@export var damage:float = 10
@export_flags("player","enemy") var affect:int = 0
@export_flags("player","enemy") var damage_type:int = 0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
print(affect)
pass # Replace with function body.
+2 -2
View File
@@ -1,7 +1,7 @@
class_name HurtBox extends Area2D
signal damage_recieved(damage:float)
@export_flags("player","enemy") var type
@export_flags("player","enemy") var respond_from
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -13,6 +13,6 @@ func _process(delta: float) -> void:
pass
func on_damage_receieved(hitbox:HitBox):
if hitbox.affect & type:
if hitbox.damage_type & respond_from:
damage_recieved.emit(hitbox.damage)
#if type