this is HPBar
extends Node2D
func _ready():
SIGNALS.connect("mini_health_changed", self, "update_mini_healthbar")
func update_mini_healthbar(value:int):
$HealthBar.texture_progress = bar_green
if value < 60:
$HealthBar.texture_progress = bar_yellow
if value < 25:
$HealthBar.texture_progress = bar_red
$HealthBar.value = value
nothing complicate I guess
to update this value i fire a signal (SIGNALS is my singleton):
SIGNALS.emit_signal("mini_health_changed",amount)
Both Player and Turret (inside Vehicle) have a func that update their HP and so fire the signal
the current setup is:
map -> Player -> vehicle
-> HPBar
map -> Turret -> vehicle
-> HPBar