diff --git a/VERSIONS.md b/VERSIONS.md index 426a0741..79640a6b 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -1,6 +1,7 @@ # 4.2.1 - Fixed snap-zones showing highlight when disabled. - Fixed pickup leaving target highlighted after picking up. +- Fixed collision hands getting stuck too far from the real hands. # 4.2.0 - Environments can now be set normally in scenes loaded through the staging system. diff --git a/addons/godot-xr-tools/hands/collision_hand.gd b/addons/godot-xr-tools/hands/collision_hand.gd index 839a0bb8..7adc4740 100644 --- a/addons/godot-xr-tools/hands/collision_hand.gd +++ b/addons/godot-xr-tools/hands/collision_hand.gd @@ -36,6 +36,9 @@ const DEFAULT_MASK := 0b0000_0000_0000_0000_1111_1111_1111_1111 # How much displacement is required for the hand to start orienting to a surface const ORIENT_DISPLACEMENT := 0.05 +# Distance to teleport hands +const TELEPORT_DISTANCE := 1.0 + ## Controls the hand collision mode @export var mode : CollisionHandMode = CollisionHandMode.COLLIDE @@ -160,6 +163,11 @@ func _move_to_target(): global_transform = _target.global_transform return + # Handle too far from target + if global_position.distance_to(_target.global_position) > TELEPORT_DISTANCE: + global_transform = _target.global_transform + return + # Orient the hand then move global_transform.basis = _target.global_transform.basis move_and_slide(_target.global_position - global_position) diff --git a/addons/godot-xr-tools/objects/snap_zone.tscn b/addons/godot-xr-tools/objects/snap_zone.tscn index c42f77fc..1348462a 100644 --- a/addons/godot-xr-tools/objects/snap_zone.tscn +++ b/addons/godot-xr-tools/objects/snap_zone.tscn @@ -3,6 +3,7 @@ [ext_resource type="Script" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="1"] [sub_resource type="SphereShape3D" id="1"] +resource_local_to_scene = true radius = 0.1 [node name="SnapZone" type="Area3D"] diff --git a/addons/godot-xr-tools/plugin.cfg b/addons/godot-xr-tools/plugin.cfg index 9d3cdddd..7e182020 100644 --- a/addons/godot-xr-tools/plugin.cfg +++ b/addons/godot-xr-tools/plugin.cfg @@ -3,5 +3,5 @@ name="Godot XR Tools" description="Godot XR Tools plugin" author="Bastiaan Olij and Contributors" -version="4.1.0" +version="4.2.1" script="plugin.gd"