From f2dbcf072d44d5b52dca5c33d5138f953fc17896 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Tue, 28 Nov 2023 15:14:21 +0100 Subject: [PATCH] fix collision system and keyboard caps --- content/entities/light/light.tscn | 2 + .../entities/media_player/media_player.tscn | 4 +- content/entities/sensor/sensor.tscn | 1 + content/entities/switch/switch.tscn | 5 +- .../controller_left/controller_left.tscn | 1 + content/system/hands/hands.tscn | 48 +++++++++++++++---- content/system/keyboard/keyboard.gd | 5 +- content/system/keyboard/keyboard.tscn | 2 + content/system/raycast/raycast.tscn | 1 + content/ui/components/button/button.tscn | 6 ++- content/ui/components/input/input.tscn | 2 + content/ui/menu/room/room_menu.gd | 20 +++++--- content/ui/menu/room/room_menu.tscn | 5 +- content/ui/menu/settings/ball.tscn | 4 +- project.godot | 8 ++++ 15 files changed, 83 insertions(+), 31 deletions(-) diff --git a/content/entities/light/light.tscn b/content/entities/light/light.tscn index 2c0a129..0d76a2f 100644 --- a/content/entities/light/light.tscn +++ b/content/entities/light/light.tscn @@ -91,6 +91,7 @@ bottom_radius = 0.006 height = 0.004 [node name="Light" type="StaticBody3D" groups=["entity"]] +collision_mask = 0 script = ExtResource("1_ykxy3") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] @@ -127,6 +128,7 @@ libraries = { [node name="Rod" type="StaticBody3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.0903599) +collision_mask = 0 [node name="MeshInstance3D" type="MeshInstance3D" parent="Rod"] mesh = SubResource("CylinderMesh_j3pn3") diff --git a/content/entities/media_player/media_player.tscn b/content/entities/media_player/media_player.tscn index dda69ea..75b72ae 100644 --- a/content/entities/media_player/media_player.tscn +++ b/content/entities/media_player/media_player.tscn @@ -8,6 +8,7 @@ size = Vector3(0.23, 0.142768, 0.01) [node name="MediaPlayer" type="StaticBody3D" groups=["entity"]] +collision_mask = 0 script = ExtResource("1_ame17") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] @@ -16,19 +17,16 @@ shape = SubResource("BoxShape3D_vi3eg") [node name="Previous" parent="." instance=ExtResource("1_8opk3")] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.07, 0, 0) -focusable = true label = "skip_previous" icon = true [node name="Play" parent="." instance=ExtResource("1_8opk3")] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -4.65661e-08, 0, 0) -focusable = true label = "pause" icon = true [node name="Next" parent="." instance=ExtResource("1_8opk3")] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.07, 0, 0) -focusable = true label = "skip_next" icon = true diff --git a/content/entities/sensor/sensor.tscn b/content/entities/sensor/sensor.tscn index 19818c2..5117fb1 100644 --- a/content/entities/sensor/sensor.tscn +++ b/content/entities/sensor/sensor.tscn @@ -7,6 +7,7 @@ radius = 0.1 [node name="Sensor" type="StaticBody3D" groups=["entity"]] +collision_mask = 0 script = ExtResource("1_57ac8") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] diff --git a/content/entities/switch/switch.tscn b/content/entities/switch/switch.tscn index b37a547..44f8635 100644 --- a/content/entities/switch/switch.tscn +++ b/content/entities/switch/switch.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=7 format=3 uid="uid://cscl5k7lhopj5"] [ext_resource type="Script" path="res://content/entities/switch/switch.gd" id="1_8ffhi"] -[ext_resource type="Texture2D" uid="uid://b72vsbcvqqxg7" path="res://assets/materials/swich_on.png" id="1_w68gw"] -[ext_resource type="Texture2D" uid="uid://cvc0o6dsktnvl" path="res://assets/materials/switch_off.png" id="2_86ba1"] +[ext_resource type="Texture2D" uid="uid://br3p0c2foputg" path="res://assets/materials/swich_on.png" id="1_w68gw"] +[ext_resource type="Texture2D" uid="uid://co2ishj2hx57p" path="res://assets/materials/switch_off.png" id="2_86ba1"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="4_6xr03"] [sub_resource type="SphereShape3D" id="SphereShape3D_ukj14"] @@ -23,6 +23,7 @@ animations = [{ }] [node name="Switch" type="StaticBody3D" groups=["entity"]] +collision_mask = 0 script = ExtResource("1_8ffhi") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] diff --git a/content/system/controller_left/controller_left.tscn b/content/system/controller_left/controller_left.tscn index 4cb4241..9e9ec9b 100644 --- a/content/system/controller_left/controller_left.tscn +++ b/content/system/controller_left/controller_left.tscn @@ -111,6 +111,7 @@ transform = Transform3D(0.03, 0, 0, 0, 0.03, 0, 0, 0, 0.03, 0.106903, -0.228617, [node name="Area3D" type="Area3D" parent="trash_bin"] transform = Transform3D(25, 0, 0, 0, 25, 0, 0, 0, 25, 0, 0, 0) +collision_layer = 0 [node name="CollisionShape3D" type="CollisionShape3D" parent="trash_bin/Area3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0542412, 0) diff --git a/content/system/hands/hands.tscn b/content/system/hands/hands.tscn index 746bd28..4c397c2 100644 --- a/content/system/hands/hands.tscn +++ b/content/system/hands/hands.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://bsx12q23v8apy"] +[gd_scene load_steps=6 format=3 uid="uid://bsx12q23v8apy"] [ext_resource type="Script" path="res://content/system/hands/hands.gd" id="1_c4f76"] [ext_resource type="PackedScene" uid="uid://c0kow4g10wolq" path="res://assets/models/hands_steam/right_hand.glb" id="1_uekbj"] @@ -8,6 +8,9 @@ radius = 0.001 height = 0.02 +[sub_resource type="BoxShape3D" id="BoxShape3D_1pxrt"] +size = Vector3(0.14, 0.0577792, 0.169383) + [node name="Hands" type="Node3D"] script = ExtResource("1_c4f76") @@ -30,8 +33,8 @@ gizmo_extents = 0.02 [node name="TouchArea" type="Area3D" parent="XRHandLeft/IndexTip"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0.01) -collision_layer = 2 -collision_mask = 2 +collision_layer = 0 +collision_mask = 4 monitorable = false [node name="CollisionShape3D" type="CollisionShape3D" parent="XRHandLeft/IndexTip/TouchArea"] @@ -60,14 +63,26 @@ gizmo_extents = 0.02 [node name="TouchArea" type="Area3D" parent="XRHandLeft/MiddleTip"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0.01) -collision_layer = 2 -collision_mask = 2 +collision_layer = 0 +collision_mask = 4 monitorable = false [node name="CollisionShape3D" type="CollisionShape3D" parent="XRHandLeft/MiddleTip/TouchArea"] transform = Transform3D(1, -7.45058e-09, -2.22045e-16, 7.45058e-09, 1, 0, 0, 0, 1, 0, 0, 0) shape = SubResource("CapsuleShape3D_dopke") +[node name="AnimatableBody3D" type="AnimatableBody3D" parent="XRHandLeft"] +transform = Transform3D(1, 8.67362e-19, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) +collision_layer = 8 +collision_mask = 8 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="XRHandLeft/AnimatableBody3D"] +transform = Transform3D(1, 8.67362e-19, 4.75779e-13, -2.32831e-10, 1, -1.77636e-14, -4.97946e-12, 1.77636e-15, 1, -7.7486e-07, 1.33878e-09, -0.030436) +shape = SubResource("BoxShape3D_1pxrt") + +[node name="RemoteTransform3D" type="RemoteTransform3D" parent="XRHandLeft"] +remote_path = NodePath("../AnimatableBody3D") + [node name="XRHandRight" type="OpenXRHand" parent="."] transform = Transform3D(0.999998, -0.000567105, -2.5179e-05, -2.51789e-05, 4.39886e-08, -0.999999, 0.000567104, 0.999999, 2.97064e-08, 0.264391, 0, 0) hand = 1 @@ -76,6 +91,9 @@ hand_skeleton = NodePath("right_hand/Armature/Skeleton3D") [node name="right_hand" parent="XRHandRight" instance=ExtResource("1_uekbj")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.033) +[node name="vr_glove_right_slim" parent="XRHandRight/right_hand/Armature/Skeleton3D" index="0"] +transform = Transform3D(1, 0, 4.7579e-13, 0, 1, 0, -1.34149e-12, 1.77636e-15, 1, 0, 0, 0) + [node name="IndexTip" type="BoneAttachment3D" parent="XRHandRight"] transform = Transform3D(0.19221, 0.669966, 0.717079, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345977, -0.164767, -0.00254008) bone_name = "Index_Tip_R" @@ -88,8 +106,8 @@ gizmo_extents = 0.02 [node name="TouchArea" type="Area3D" parent="XRHandRight/IndexTip"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0.01) -collision_layer = 2 -collision_mask = 2 +collision_layer = 0 +collision_mask = 4 monitorable = false [node name="CollisionShape3D" type="CollisionShape3D" parent="XRHandRight/IndexTip/TouchArea"] @@ -118,13 +136,25 @@ gizmo_extents = 0.02 [node name="TouchArea" type="Area3D" parent="XRHandRight/MiddleTip"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0.01) -collision_layer = 2 -collision_mask = 2 +collision_layer = 0 +collision_mask = 4 monitorable = false [node name="CollisionShape3D" type="CollisionShape3D" parent="XRHandRight/MiddleTip/TouchArea"] transform = Transform3D(1, -7.45058e-09, -2.22045e-16, 7.45058e-09, 1, 0, 0, 0, 1, 0, 0, 0) shape = SubResource("CapsuleShape3D_dopke") +[node name="AnimatableBody3D" type="AnimatableBody3D" parent="XRHandRight"] +transform = Transform3D(1, 0, 4.7579e-13, -5.82077e-11, 1, 0, -4.97947e-12, 1.77636e-15, 1, 0, 0, 0) +collision_layer = 8 +collision_mask = 8 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="XRHandRight/AnimatableBody3D"] +transform = Transform3D(1, 0, 4.75779e-13, -2.32831e-10, 1, -1.77636e-14, -4.97946e-12, 1.77636e-15, 1, -7.7486e-07, 1.33878e-09, -0.030436) +shape = SubResource("BoxShape3D_1pxrt") + +[node name="RemoteTransform3D" type="RemoteTransform3D" parent="XRHandRight"] +remote_path = NodePath("../AnimatableBody3D") + [editable path="XRHandLeft/left_hand"] [editable path="XRHandRight/right_hand"] diff --git a/content/system/keyboard/keyboard.gd b/content/system/keyboard/keyboard.gd index 36c2a3f..947e5f1 100644 --- a/content/system/keyboard/keyboard.gd +++ b/content/system/keyboard/keyboard.gd @@ -79,11 +79,10 @@ func create_key(key: Key): func update_labels(): for key_button in keys.get_children(): - var label = key_button.get_children()[key_button.get_children().size() - 1] if caps: - label.text = label.text.to_upper() + key_button.label = key_button.label.to_upper() else: - label.text = label.text.to_lower() + key_button.label = key_button.label.to_lower() func _emit_event(type: String, key: Key): var event = EventKey.new() diff --git a/content/system/keyboard/keyboard.tscn b/content/system/keyboard/keyboard.tscn index 2e891f5..539dff2 100644 --- a/content/system/keyboard/keyboard.tscn +++ b/content/system/keyboard/keyboard.tscn @@ -13,6 +13,8 @@ size = Vector3(0.79, 0.01, 0.26) [node name="Keyboard" type="StaticBody3D" groups=["ui_focus_stop"]] transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) +collision_layer = 2 +collision_mask = 2 script = ExtResource("1_maojw") [node name="Backspace" parent="." instance=ExtResource("1_xdpwr")] diff --git a/content/system/raycast/raycast.tscn b/content/system/raycast/raycast.tscn index 727eb3c..55e4b3d 100644 --- a/content/system/raycast/raycast.tscn +++ b/content/system/raycast/raycast.tscn @@ -6,6 +6,7 @@ [node name="Raycast" type="RayCast3D"] transform = Transform3D(0.999999, -1.39624e-11, 0, 9.48108e-12, 0.999999, 0, 0, 4.54747e-13, 0.999998, -0.000467122, 0.00228411, -0.0016689) target_position = Vector3(0, 0, -5) +collision_mask = 19 script = ExtResource("1_gp8nv") [node name="Decal" type="Decal" parent="."] diff --git a/content/ui/components/button/button.tscn b/content/ui/components/button/button.tscn index e0836ef..54cde07 100644 --- a/content/ui/components/button/button.tscn +++ b/content/ui/components/button/button.tscn @@ -77,6 +77,8 @@ label = "Example Text" [node name="Body" type="StaticBody3D" parent="." groups=["ui_focus_skip"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.01, 0) +collision_layer = 2 +collision_mask = 0 [node name="MeshInstance3D" type="MeshInstance3D" parent="Body"] transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.005, 0) @@ -103,8 +105,8 @@ libraries = { [node name="FingerArea" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0101447, 0) -collision_layer = 2 -collision_mask = 2 +collision_layer = 4 +collision_mask = 0 monitoring = false [node name="CollisionShape3D" type="CollisionShape3D" parent="FingerArea"] diff --git a/content/ui/components/input/input.tscn b/content/ui/components/input/input.tscn index ff9666c..0aefa4c 100644 --- a/content/ui/components/input/input.tscn +++ b/content/ui/components/input/input.tscn @@ -53,6 +53,8 @@ _data = { } [node name="Input" type="StaticBody3D" groups=["ui_focus"]] +collision_layer = 2 +collision_mask = 0 script = ExtResource("1_uml3t") width = 0.2 text = "Example" diff --git a/content/ui/menu/room/room_menu.gd b/content/ui/menu/room/room_menu.gd index 9e1eddd..82a4485 100644 --- a/content/ui/menu/room/room_menu.gd +++ b/content/ui/menu/room/room_menu.gd @@ -27,10 +27,17 @@ func _ready(): add_corner(event.ray.get_collision_point()) ) - toggle_edit_button.get_node("Clickable").on_press_up.connect(func(event): - edit_enabled = event.target.active + toggle_edit_button.on_button_down.connect(func(): + edit_enabled = true + + wall_corners.visible = true + wall_edges.visible = true + wall_mesh.visible = false + ) + + toggle_edit_button.on_button_up.connect(func(): + edit_enabled = false - if edit_enabled == false: wall_corners.visible = false wall_edges.visible = false wall_mesh.mesh = generate_mesh() @@ -45,14 +52,13 @@ func _ready(): for collision in collisions: var static_body = StaticBody3D.new() + static_body.set_collision_layer_value(4, true) + static_body.set_collision_layer_value(5, true) + static_body.collision_mask = 0 static_body.add_child(collision) wall_collisions.add_child(static_body) wall_mesh.visible = true - else: - wall_corners.visible = true - wall_edges.visible = true - wall_mesh.visible = false ) func generate_mesh(): diff --git a/content/ui/menu/room/room_menu.tscn b/content/ui/menu/room/room_menu.tscn index 7f956bc..71a507b 100644 --- a/content/ui/menu/room/room_menu.tscn +++ b/content/ui/menu/room/room_menu.tscn @@ -18,8 +18,8 @@ script = ExtResource("1_ch4jb") [node name="TeleportRoot" type="Node3D" parent="."] [node name="Ground" type="StaticBody3D" parent="TeleportRoot"] -collision_layer = 5 -collision_mask = 5 +collision_layer = 24 +collision_mask = 0 [node name="CollisionShape3D" type="CollisionShape3D" parent="TeleportRoot/Ground"] shape = SubResource("WorldBoundaryShape3D_08sv0") @@ -46,7 +46,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.01, 0) [node name="ToggleEdit" parent="Interface" instance=ExtResource("3_whl7a")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, 0, 0.05) -focusable = true label = "room_preferences" icon = true toggleable = true diff --git a/content/ui/menu/settings/ball.tscn b/content/ui/menu/settings/ball.tscn index fc99630..b982d05 100644 --- a/content/ui/menu/settings/ball.tscn +++ b/content/ui/menu/settings/ball.tscn @@ -9,8 +9,8 @@ bounce = 0.7 radius = 0.08 [node name="Ball" type="RigidBody3D"] -collision_layer = 4 -collision_mask = 4 +collision_layer = 8 +collision_mask = 24 physics_material_override = SubResource("PhysicsMaterial_f6jtg") angular_damp = 4.0 diff --git a/project.godot b/project.godot index 48881ea..800e839 100644 --- a/project.godot +++ b/project.godot @@ -36,6 +36,14 @@ import/fbx/enabled=false theme/custom_font="res://assets/fonts/ui_font_500.tres" +[layer_names] + +3d_physics/layer_1="entities" +3d_physics/layer_2="interface" +3d_physics/layer_3="touch" +3d_physics/layer_4="physics" +3d_physics/layer_5="room" + [rendering] renderer/rendering_method="mobile"