From 2f3cce84f98ee335f568cc115751f34fa1254eaa Mon Sep 17 00:00:00 2001 From: Nitwel Date: Mon, 6 May 2024 20:35:31 +0200 Subject: [PATCH 1/2] only have physics hands in touch areas --- app/content/ui/menu/menu.tscn | 14 +++++++++++++- app/lib/utils/touch/collide.gd | 12 ++++++++++++ app/lib/utils/touch/touch.gd | 3 +++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index f5e5027..2a40330 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=20 format=3 uid="uid://c3kdssrmv84kv"] +[gd_scene load_steps=21 format=3 uid="uid://c3kdssrmv84kv"] [ext_resource type="Script" path="res://content/ui/menu/menu.gd" id="1_ng4u3"] [ext_resource type="Script" path="res://content/functions/movable.gd" id="2_8coxu"] @@ -187,6 +187,9 @@ _data = { "hide_menu": SubResource("Animation_lkh72") } +[sub_resource type="BoxShape3D" id="BoxShape3D_emmtq"] +size = Vector3(0.503906, 0.355225, 0.148712) + [node name="Menu" type="StaticBody3D"] collision_layer = 6 collision_mask = 6 @@ -293,3 +296,12 @@ mesh = ExtResource("7_f4u4o") libraries = { "": SubResource("AnimationLibrary_s30cd") } + +[node name="Area3D" type="Area3D" parent="."] +collision_layer = 4 +collision_mask = 0 +monitoring = false + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.0194855) +shape = SubResource("BoxShape3D_emmtq") diff --git a/app/lib/utils/touch/collide.gd b/app/lib/utils/touch/collide.gd index 8912d80..3572ace 100644 --- a/app/lib/utils/touch/collide.gd +++ b/app/lib/utils/touch/collide.gd @@ -27,10 +27,20 @@ func _ready(): func _physics_process(_delta): _move_tip_rigidbody_to_bone(tip_body, tip) +var last_run_active = false + func _move_tip_rigidbody_to_bone(tip_rigidbody: RigidBody3D, tip_bone: Node3D): if tip_rigidbody.is_inside_tree() == false: return + if TouchManager.is_touching() == false: + hand_mesh.position = Vector3.ZERO + last_run_active = false + return + + if last_run_active == false: + tip_rigidbody.global_position = tip_bone.global_position + var move_delta: Vector3 = tip_bone.global_position - tip_rigidbody.global_position hand_mesh.global_position = hand.global_position - move_delta @@ -43,3 +53,5 @@ func _move_tip_rigidbody_to_bone(tip_rigidbody: RigidBody3D, tip_bone: Node3D): var coef_force = 30.0 tip_rigidbody.apply_central_force(move_delta * coef_force) tip_rigidbody.global_transform.basis = hand.global_transform.basis + + last_run_active = true diff --git a/app/lib/utils/touch/touch.gd b/app/lib/utils/touch/touch.gd index 1c29ab9..c58125a 100644 --- a/app/lib/utils/touch/touch.gd +++ b/app/lib/utils/touch/touch.gd @@ -8,6 +8,9 @@ var finger_areas: Dictionary var areas_entered = {} +func is_touching() -> bool: + return areas_entered.keys().size() > 0 + func add_finger(finger_type: Finger.Type, area: Area3D): finger_areas[finger_type] = area From b4395632b00193a60e251fdee5eb2cab8c3ad507 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Mon, 6 May 2024 20:36:57 +0200 Subject: [PATCH 2/2] fix menu touch area --- app/content/ui/menu/menu.tscn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index 2a40330..38ecc2d 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -188,7 +188,7 @@ _data = { } [sub_resource type="BoxShape3D" id="BoxShape3D_emmtq"] -size = Vector3(0.503906, 0.355225, 0.148712) +size = Vector3(0.542114, 0.355225, 0.0774612) [node name="Menu" type="StaticBody3D"] collision_layer = 6 @@ -303,5 +303,5 @@ collision_mask = 0 monitoring = false [node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.0194855) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0299683, 0, 0.00889969) shape = SubResource("BoxShape3D_emmtq")