Added health bars
This commit is contained in:
18
client/player/health/HealthComponent.gd
Normal file
18
client/player/health/HealthComponent.gd
Normal file
@ -0,0 +1,18 @@
|
||||
class_name HealthComponent
|
||||
extends Node
|
||||
|
||||
signal value_changed
|
||||
|
||||
@export var max_value: float
|
||||
var value: float
|
||||
|
||||
func _ready():
|
||||
value = max_value
|
||||
value_changed.emit()
|
||||
|
||||
func take_damage(attack: DamageInstance):
|
||||
value -= attack.damage
|
||||
value_changed.emit()
|
||||
|
||||
if value <= 0:
|
||||
owner.queue_free()
|
Reference in New Issue
Block a user