From 116b09b047c9ff9bc8e0f2e1acff80b279ada03a Mon Sep 17 00:00:00 2001 From: copygirl Date: Tue, 2 Jan 2024 13:20:58 +0100 Subject: [PATCH] Fix pickup controller not being rotated correctly --- player/AnimationController.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/player/AnimationController.cs b/player/AnimationController.cs index 8f49fd2..f4b55f7 100644 --- a/player/AnimationController.cs +++ b/player/AnimationController.cs @@ -166,13 +166,15 @@ public partial class AnimationController : Node3D Vector3? _defaultPickupPosition; void HandleHoldingAnimation(double delta) { - var posPickup = _defaultPickupPosition ??= _player.Pickup.Position; - posPickup = _player.GlobalPosition + posPickup.Rotated(Vector3.Up, Tau / 2 + _bones["UpperBody"].GlobalRotation.Y); - var posWristR = _bones["Wrist_R"].GlobalPosition; var posWristL = _bones["Wrist_L"].GlobalPosition; + var bodyYaw = _bones["UpperBody"].GlobalRotation.Y; + + var posPickup = _defaultPickupPosition ??= _player.Pickup.Position; + posPickup = _player.GlobalPosition + posPickup.Rotated(Vector3.Up, Tau / 2 + bodyYaw); + _player.Pickup.GlobalPosition = (posPickup + posWristR + posWristL) / 3; - _player.Pickup.Rotation = _player.Pickup.Rotation with { Y = _bones["UpperBody"].Rotation.Y }; + _player.Pickup.GlobalRotation = _player.Pickup.GlobalRotation with { Y = bodyYaw }; const string IsHoldingParam = "parameters/is_holding/blend_amount";