From 9599d80b62bbeecb4df2db16409b0f308227bf97 Mon Sep 17 00:00:00 2001 From: SyntaX Date: Tue, 19 Nov 2019 12:08:11 +0100 Subject: [PATCH] - preparations for HUD --- Characters/Player/Player.gd | 3 +++ Characters/Player/Player.tscn | 5 ++++- Characters/Player/UI/UI.tscn | 14 ++++++++++++++ Level/PathTestWorld.tscn | 16 +--------------- 4 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 Characters/Player/UI/UI.tscn diff --git a/Characters/Player/Player.gd b/Characters/Player/Player.gd index cb13815..03d0475 100644 --- a/Characters/Player/Player.gd +++ b/Characters/Player/Player.gd @@ -35,6 +35,9 @@ func _ready(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) _lookCast = get_node(lookingAt_nodepath) as RayCast _lookCast.cast_to = Vector3(0, 0, INTERACT_DISTANCE) + + # TODO: move to Designer: + ui_interact_nodepath = get_node("HUD").get_node("PressInteract").get_path() func _physics_process(delta): diff --git a/Characters/Player/Player.tscn b/Characters/Player/Player.tscn index 0d5a1b9..730d7a6 100644 --- a/Characters/Player/Player.tscn +++ b/Characters/Player/Player.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://Characters/Player/Player.gd" type="Script" id=1] +[ext_resource path="res://Characters/Player/UI/UI.tscn" type="PackedScene" id=2] [sub_resource type="CylinderShape" id=1] @@ -27,3 +28,5 @@ cast_to = Vector3( 0, 0, 2 ) [node name="Collider" type="CollisionShape" parent="."] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 ) shape = SubResource( 1 ) + +[node name="HUD" parent="." instance=ExtResource( 2 )] diff --git a/Characters/Player/UI/UI.tscn b/Characters/Player/UI/UI.tscn new file mode 100644 index 0000000..562d335 --- /dev/null +++ b/Characters/Player/UI/UI.tscn @@ -0,0 +1,14 @@ +[gd_scene format=2] + +[node name="HUD" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 1.948 +margin_right = 1.948 + +[node name="PressInteract" type="Label" parent="."] +margin_left = 453.005 +margin_top = 515.582 +margin_right = 569.005 +margin_bottom = 529.582 +text = "Press E to interact" diff --git a/Level/PathTestWorld.tscn b/Level/PathTestWorld.tscn index aed38db..61c4a82 100644 --- a/Level/PathTestWorld.tscn +++ b/Level/PathTestWorld.tscn @@ -34,13 +34,13 @@ extents = Vector3( 10, 1, 10 ) [node name="Player" parent="." instance=ExtResource( 1 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.634059, 0.9426, 8.83401 ) -ui_interact_nodepath = NodePath("../UI/PressInteract") [node name="DirectionalLight" type="DirectionalLight" parent="."] transform = Transform( 0.766044, -0.582564, 0.271654, 0, 0.422618, 0.906308, -0.642788, -0.694272, 0.323744, 0, 5, 0 ) light_energy = 0.19 [node name="NavigationMeshInstance" type="NavigationMeshInstance" parent="."] +editor/display_folded = true navmesh = SubResource( 1 ) [node name="MeshInstance" type="MeshInstance" parent="NavigationMeshInstance"] @@ -108,17 +108,3 @@ door_lvl = 1 transform = Transform( -2.18557e-008, 0, 0.5, 0, 0.5, 0, -0.5, 0, -2.18557e-008, -10, 1, 6 ) card_door = true door_lvl = 1 - -[node name="UI" type="Control" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 - -[node name="PressInteract" type="Label" parent="UI"] -margin_left = 454.0 -margin_top = 500.0 -margin_right = 570.0 -margin_bottom = 514.0 -custom_colors/font_color = Color( 1, 1, 1, 1 ) -custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 ) -custom_colors/font_color_shadow = Color( 0, 0, 0, 1 ) -text = "Press E to interact"