From 943325ce4b0e0ba7bc83c5567b34fbaf9bee6fad Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 31 Aug 2025 14:07:03 +0200 Subject: [PATCH] feat: player health status updates HUD --- project/objects/player.tscn | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/project/objects/player.tscn b/project/objects/player.tscn index 978e5a8a..2d3fb96b 100644 --- a/project/objects/player.tscn +++ b/project/objects/player.tscn @@ -10,6 +10,12 @@ script/source = "extends HealthStatus func _on_death() -> void: get_tree().change_scene_to_file.call_deferred(\"res://guis/main_menu.tscn\") + + +func _on_health_changed(remaining: int, _delta: int) -> void: + var hud := HeadsUpDisplay.get_singleton() + if hud: + hud.set_health_percentage(float(remaining) / float(self.get_max_health())) " [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_bxedw"] @@ -61,3 +67,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) shape = SubResource("CapsuleShape3D_eqqp1") [connection signal="death" from="HealthStatus" to="HealthStatus" method="_on_death"] +[connection signal="health_changed" from="HealthStatus" to="HealthStatus" method="_on_health_changed"]