From fada7c657bb0b8fe86f220a5b10e7f1a3378d099 Mon Sep 17 00:00:00 2001 From: Clevertop Date: Sat, 10 Aug 2024 17:12:20 +1000 Subject: [PATCH] terminal ui comes up --- Levels/StartingRoom.tscn | 15 ++++++++++++--- Scripts/ChronoManager.gd | 5 +++++ Scripts/Player.gd | 9 ++++++++- player.tscn | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Levels/StartingRoom.tscn b/Levels/StartingRoom.tscn index ed869e2..5a834d0 100644 --- a/Levels/StartingRoom.tscn +++ b/Levels/StartingRoom.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://bojbawyoy11i4"] +[gd_scene load_steps=14 format=3 uid="uid://bojbawyoy11i4"] [ext_resource type="Script" path="res://Scripts/ChronoManager.gd" id="1_5b2rd"] [ext_resource type="Material" uid="uid://cr4ra7ijk1uec" path="res://Assets/Materials/floor.tres" id="2_0aj3l"] @@ -31,11 +31,15 @@ material = SubResource("StandardMaterial3D_itc1d") [sub_resource type="BoxShape3D" id="BoxShape3D_y4l56"] +[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_mfjp6"] +data = PackedVector3Array(-0.5, 1, 0.5, 0.5, 1, 0.5, -0.5, -1, 0.5, 0.5, 1, 0.5, 0.5, -1, 0.5, -0.5, -1, 0.5, 0.5, 1, -0.5, -0.5, 1, -0.5, 0.5, -1, -0.5, -0.5, 1, -0.5, -0.5, -1, -0.5, 0.5, -1, -0.5, 0.5, 1, 0.5, 0.5, 1, -0.5, 0.5, -1, 0.5, 0.5, 1, -0.5, 0.5, -1, -0.5, 0.5, -1, 0.5, -0.5, 1, -0.5, -0.5, 1, 0.5, -0.5, -1, -0.5, -0.5, 1, 0.5, -0.5, -1, 0.5, -0.5, -1, -0.5, 0.5, 1, 0.5, -0.5, 1, 0.5, 0.5, 1, -0.5, -0.5, 1, 0.5, -0.5, 1, -0.5, 0.5, 1, -0.5, -0.5, -1, 0.5, 0.5, -1, 0.5, -0.5, -1, -0.5, 0.5, -1, 0.5, 0.5, -1, -0.5, -0.5, -1, -0.5) + [sub_resource type="BoxMesh" id="BoxMesh_u6v2s"] size = Vector3(1, 2, 1) -[node name="ChronoManager" type="Node3D"] +[node name="ChronoManager" type="Node3D" node_paths=PackedStringArray("gui")] script = ExtResource("1_5b2rd") +gui = NodePath("Gui") [node name="Player" parent="." instance=ExtResource("2_hsi55")] @@ -61,8 +65,13 @@ mesh = SubResource("BoxMesh_lcav8") [node name="CollisionShape3D" type="CollisionShape3D" parent="EndZone/Area3D"] shape = SubResource("BoxShape3D_y4l56") -[node name="Terminal" type="Node3D" parent="."] +[node name="Terminal" type="StaticBody3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.50596, 2.93638, 3.58967) +[node name="CollisionShape3D" type="CollisionShape3D" parent="Terminal"] +shape = SubResource("ConcavePolygonShape3D_mfjp6") + [node name="MeshInstance3D" type="MeshInstance3D" parent="Terminal"] mesh = SubResource("BoxMesh_u6v2s") + +[connection signal="object_clicked" from="Player" to="." method="_on_player_object_clicked"] diff --git a/Scripts/ChronoManager.gd b/Scripts/ChronoManager.gd index 1a1ec5c..4b7ed2b 100644 --- a/Scripts/ChronoManager.gd +++ b/Scripts/ChronoManager.gd @@ -44,3 +44,8 @@ func open_termimal(): Input.mouse_mode = Input.MOUSE_MODE_VISIBLE #display terminal ui pass + + +func _on_player_object_clicked(object): + if(object.name == "Terminal"): + open_termimal() diff --git a/Scripts/Player.gd b/Scripts/Player.gd index 3922d0f..c4ff2de 100644 --- a/Scripts/Player.gd +++ b/Scripts/Player.gd @@ -4,6 +4,8 @@ extends CharacterBody3D @export var mouse_sensitivity : float = 0.003 # TODO: this is sketchy check that its framerate independant pls @export var raycast : RayCast3D +signal object_clicked(object : Node3D) + const SPEED = 5.0 const JUMP_VELOCITY = 4.5 @@ -31,7 +33,12 @@ func _physics_process(delta): # interact with stuff if Input.is_action_just_pressed("interact"): - print(raycast.) + if "name" in raycast.get_collider(): + print(raycast.get_collider().name) + object_clicked.emit(raycast.get_collider()) + else: + print("womp womp") + # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. diff --git a/player.tscn b/player.tscn index 0799cc8..c3f1098 100644 --- a/player.tscn +++ b/player.tscn @@ -10,7 +10,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.83982, 0) script = ExtResource("1_tc5d2") camera = NodePath("Camera3D") -mouse_sensitivity = null raycast = NodePath("Camera3D/RayCast3D") [node name="MeshInstance3D2" type="MeshInstance3D" parent="."] @@ -23,6 +22,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.621505, 0) [node name="RayCast3D" type="RayCast3D" parent="Camera3D"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0) target_position = Vector3(0, -4, 0) +collide_with_areas = true [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("CapsuleShape3D_a6eig")