diff --git a/app/content/functions/movable.gd b/app/content/functions/movable.gd index 1937512..4447883 100644 --- a/app/content/functions/movable.gd +++ b/app/content/functions/movable.gd @@ -9,17 +9,26 @@ signal on_moved() @export var restrict_movement: Callable @export var lock_rotation: bool = false var hit_node := Node3D.new() +var initiator = null func _on_grab_down(event: EventPointer): - if restricted && event.target != get_parent(): + if restricted&&event.target != get_parent(): return - event.initiator.node.add_child(hit_node) + initiator = event.initiator + + if hit_node.get_parent() != null: + hit_node.get_parent().remove_child(hit_node) + + initiator.node.add_child(hit_node) hit_node.global_transform = get_parent().global_transform -func _on_grab_move(_event: EventPointer): +func _on_grab_move(event: EventPointer): if hit_node.get_parent() == null: return + + if event.initiator != initiator: + return if restrict_movement: get_parent().global_position = restrict_movement.call(hit_node.global_position) @@ -33,7 +42,14 @@ func _on_grab_move(_event: EventPointer): on_move.emit(get_parent().global_position, Vector3(0, 0, 0)) func _on_grab_up(event: EventPointer): - event.initiator.node.remove_child(hit_node) + if event.initiator != initiator: + return + + if hit_node.get_parent() == null: + return + + initiator = null + hit_node.get_parent().remove_child(hit_node) on_moved.emit() func _get_configuration_warnings() -> PackedStringArray: @@ -41,6 +57,5 @@ func _get_configuration_warnings() -> PackedStringArray: if get_parent() is StaticBody3D == false: warnings.append("Movable requires a StaticBody3D as parent.") - return warnings diff --git a/app/content/system/hands/hands.gd b/app/content/system/hands/hands.gd index fe208a5..26e378a 100644 --- a/app/content/system/hands/hands.gd +++ b/app/content/system/hands/hands.gd @@ -122,12 +122,12 @@ func _process_hand(hand: OpenXRHand): initiator.on_release.emit(Initiator.EventType.GRIP) grabbed_left = false else: - if trigger_close&&!grabbed_right: + if trigger_close&&!grabbed_left: initiator.on_press.emit(Initiator.EventType.GRIP) - grabbed_right = true - elif !trigger_close&&grabbed_right: + grabbed_left = true + elif !trigger_close&&grabbed_left: initiator.on_release.emit(Initiator.EventType.GRIP) - grabbed_right = false + grabbed_left = false else: if !distance_close: if trigger_close&&!pressed_right: diff --git a/app/content/ui/components/button/button.tscn b/app/content/ui/components/button/button.tscn index ece8aeb..881bb56 100644 --- a/app/content/ui/components/button/button.tscn +++ b/app/content/ui/components/button/button.tscn @@ -45,7 +45,7 @@ outline_size = 0 autowrap_mode = 3 width = 40.0 -[node name="FingerArea" type="Area3D" parent="."] +[node name="FingerArea" type="Area3D" parent="." groups=["ui_focus_skip"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.015) collision_layer = 4 collision_mask = 0 diff --git a/app/content/ui/menu/menu.tscn b/app/content/ui/menu/menu.tscn index fb9e111..b0ab2de 100644 --- a/app/content/ui/menu/menu.tscn +++ b/app/content/ui/menu/menu.tscn @@ -188,8 +188,8 @@ _data = { } [node name="Menu" type="StaticBody3D"] -collision_layer = 2 -collision_mask = 2 +collision_layer = 6 +collision_mask = 6 script = ExtResource("1_ng4u3") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] @@ -199,14 +199,8 @@ shape = SubResource("BoxShape3D_e1esh") [node name="Movable" type="Node" parent="."] script = ExtResource("2_8coxu") -[node name="AnimationContainer" type="StaticBody3D" parent="."] +[node name="AnimationContainer" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23, 0.15, 0) -collision_layer = 6 -collision_mask = 6 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="AnimationContainer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, -0.15, -0.005) -shape = SubResource("BoxShape3D_e1esh") [node name="Background" type="MeshInstance3D" parent="AnimationContainer"] transform = Transform3D(1, 0, 0, 0, 1, 1.06581e-14, 0, -1.06581e-14, 1, 0.23, -0.15, 0)