Skip to content

Commit

Permalink
do not grab/drop based on hand poses when we receive data from contro…
Browse files Browse the repository at this point in the history
…ller
  • Loading branch information
patrykkalinowski committed Dec 3, 2023
1 parent 8ba358f commit 5720569
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/xr-kit/physics-movement/scenes/player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
9 changes: 9 additions & 0 deletions addons/xr-kit/physics-movement/scripts/physics_hand.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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

0 comments on commit 5720569

Please sign in to comment.