Add HUD presenter component and player HUD scene for health and ammo display

This commit is contained in:
2025-10-29 02:59:02 +01:00
parent 853378c9c6
commit 9c0cd3f549
5 changed files with 173 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
[gd_scene load_steps=2 format=3 uid="uid://b36xmciamjyc0"]
[ext_resource type="Script" uid="uid://c6nouigv5wsu1" path="res://Code/Presenters/HudPresenterComponent.cs" id="1_yd76s"]
[node name="PlayerHUD" type="Control" node_paths=PackedStringArray("_healthLabel", "_ammoLabel", "_weaponLabel")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_yd76s")
_healthLabel = NodePath("MarginContainer/HBoxContainer/HealthLabel")
_ammoLabel = NodePath("MarginContainer/HBoxContainer/AmmoLabel")
_weaponLabel = NodePath("MarginContainer/HBoxContainer/WeaponLabel")
metadata/_custom_type_script = "uid://c6nouigv5wsu1"
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="HealthLabel" type="Label" parent="MarginContainer/HBoxContainer"]
layout_mode = 2
text = "health 100"
uppercase = true
[node name="AmmoLabel" type="Label" parent="MarginContainer/HBoxContainer"]
layout_mode = 2
text = "ammo 100"
uppercase = true
[node name="WeaponLabel" type="Label" parent="MarginContainer/HBoxContainer"]
layout_mode = 2
text = "gun"
uppercase = true

View File

@@ -1,6 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://c576jiewfs5gj"]
[gd_scene load_steps=6 format=3 uid="uid://c576jiewfs5gj"]
[ext_resource type="Script" uid="uid://hkiny1ftv4r7" path="res://Code/Presenters/CharacterBody3DPresenter.cs" id="2_3y5cq"]
[ext_resource type="PackedScene" uid="uid://b36xmciamjyc0" path="res://Objects/UI/player_hud.tscn" id="3_0ad8t"]
[ext_resource type="Script" uid="uid://crx03e8buoni3" path="res://Code/Presenters/CameraPresenterComponent.cs" id="3_2i4gt"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_y0qk3"]
@@ -26,3 +27,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5901337, 0)
script = ExtResource("3_2i4gt")
[node name="Camera3D" type="Camera3D" parent="CameraPivot"]
[node name="PlayerHUD" parent="." instance=ExtResource("3_0ad8t")]