Added health bars
This commit is contained in:
21
client/player/hud/HealthBar.gd
Normal file
21
client/player/hud/HealthBar.gd
Normal file
@ -0,0 +1,21 @@
|
||||
extends TextureProgressBar
|
||||
|
||||
@export var high: Texture2D
|
||||
@export var medium: Texture2D
|
||||
@export var low: Texture2D
|
||||
|
||||
var health: HealthComponent
|
||||
|
||||
func _ready():
|
||||
health = owner.health
|
||||
health.value_changed.connect(on_health_changed)
|
||||
|
||||
func on_health_changed():
|
||||
value = health.value / health.max_value
|
||||
|
||||
if value < 0.45:
|
||||
texture_progress = low
|
||||
elif value < 0.75:
|
||||
texture_progress = medium
|
||||
else:
|
||||
texture_progress = high
|
Reference in New Issue
Block a user