From 57205696449d6f92c60d062a1e1b401b57b74a2e Mon Sep 17 00:00:00 2001 From: Patryk Kalinowski Date: Sun, 3 Dec 2023 19:10:57 +0100 Subject: [PATCH] do not grab/drop based on hand poses when we receive data from controller --- addons/xr-kit/physics-movement/scenes/player.tscn | 1 + addons/xr-kit/physics-movement/scripts/physics_hand.gd | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/addons/xr-kit/physics-movement/scenes/player.tscn b/addons/xr-kit/physics-movement/scenes/player.tscn index 9595623..53638fa 100644 --- a/addons/xr-kit/physics-movement/scenes/player.tscn +++ b/addons/xr-kit/physics-movement/scenes/player.tscn @@ -1534,6 +1534,7 @@ target_position = Vector3(0, 0, 0) [connection signal="thruster_brake" from="Body/XROrigin3D/XRController3D Left" to="Body" method="_on_thruster_brake"] [connection signal="tracking_changed" from="Body/XROrigin3D/XRController3D Left" to="Body/XROrigin3D/XRController3D Left" method="_on_tracking_changed"] [connection signal="tracking_changed" from="Body/XROrigin3D/XRController3D Left" to="Body/XROrigin3D/OpenXRHand Left/Controller Skeleton3D Left/AnimationTree" method="_on_controller_tracking_changed"] +[connection signal="tracking_changed" from="Body/XROrigin3D/XRController3D Left" to="PhysicsHandLeft" method="_on_controller_tracking_changed"] [connection signal="trigger" from="Body/XROrigin3D/XRController3D Left" to="Body/XROrigin3D/OpenXRHand Left/Controller Skeleton3D Left/AnimationTree" method="_on_trigger"] [connection signal="turned_x" from="Body/XROrigin3D/XRController3D Left" to="Body" method="_on_turned_x"] [connection signal="button_pressed" from="Body/XROrigin3D/XRController3D Right" to="Body/XROrigin3D/XRController3D Right" method="_on_button_pressed"] diff --git a/addons/xr-kit/physics-movement/scripts/physics_hand.gd b/addons/xr-kit/physics-movement/scripts/physics_hand.gd index da87f14..47a2e61 100644 --- a/addons/xr-kit/physics-movement/scripts/physics_hand.gd +++ b/addons/xr-kit/physics-movement/scripts/physics_hand.gd @@ -34,6 +34,7 @@ var thruster_forward: bool var thruster_backward: bool var reset_transform := Transform3D.IDENTITY var resetting_hand := false +var is_controller_tracking: bool func _ready() -> void: @@ -273,6 +274,10 @@ func _on_grab(grab: bool) -> void: func _on_hand_pose_recognition_new_pose(previous_pose: StringName, pose: StringName) -> void: + # do not grab/drop based on hand poses when we receive data from controller + if is_controller_tracking: + return + if pose in ["half_grip", "full_grip", "thumb_up", "point"] and previous_pose in ["open", "rest"]: grab() @@ -321,3 +326,7 @@ class PIDController: output = Kp * proportional + Ki * integral + Kd * derivative return output + + +func _on_controller_tracking_changed(tracking: bool) -> void: + is_controller_tracking = tracking