From 1fe3faf4a6e1a4813a7c9cac240b027266264a15 Mon Sep 17 00:00:00 2001 From: hiina Date: Thu, 13 Feb 2025 20:16:25 -0700 Subject: [PATCH] smooth world grab else it oscillates badly for some reason. it still kind of does even here, but it's better. --- addons/godot-xr-tools/functions/movement_world_grab.gd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/godot-xr-tools/functions/movement_world_grab.gd b/addons/godot-xr-tools/functions/movement_world_grab.gd index ea6b144..7b63c1a 100644 --- a/addons/godot-xr-tools/functions/movement_world_grab.gd +++ b/addons/godot-xr-tools/functions/movement_world_grab.gd @@ -130,9 +130,11 @@ func physics_movement(delta: float, player_body: XRToolsPlayerBody, disabled: bo player_body.rotate_player(angle) # Apply scale - var new_world_scale := XRServer.world_scale * grab_l2r.length() / pickup_l2r.length() - new_world_scale = clamp(new_world_scale, world_scale_min, world_scale_max) - XRServer.world_scale = new_world_scale + var target_world_scale := XRServer.world_scale * grab_l2r.length() / pickup_l2r.length() + target_world_scale = clamp(target_world_scale, world_scale_min, world_scale_max) + # lerp a bit. applying the scale directly causes fast oscillations as the + # controller positions get scaled to match the world scale. + XRServer.world_scale = lerp(XRServer.world_scale, target_world_scale, 0.1) # Apply offset offset = pickup_mid - grab_mid