From 6ea8aa4df497ed59e1bcaef870989160c59eb2aa Mon Sep 17 00:00:00 2001 From: "qsxft258@gmail.com" Date: Sat, 29 Nov 2025 20:26:51 +0900 Subject: [PATCH] =?UTF-8?q?Fix=20:=20=EB=B2=8C=EC=96=B4=EC=A7=80=EB=8A=94?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomRetargetingScript.cs | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/Assets/Scripts/KindRetargeting/CustomRetargetingScript.cs b/Assets/Scripts/KindRetargeting/CustomRetargetingScript.cs index ccccb5c3..73ff56e1 100644 --- a/Assets/Scripts/KindRetargeting/CustomRetargetingScript.cs +++ b/Assets/Scripts/KindRetargeting/CustomRetargetingScript.cs @@ -1164,29 +1164,37 @@ namespace KindRetargeting // 바닥 높이 적용 targetPosition.y += floorHeight; - // 소스 아바타의 로컬 축 기준으로 발 오프셋 적용 + // 발 본의 로컬 좌표계 기준으로 오프셋 적용 // +Z: 앞으로, -Z: 뒤로 // 왼발: +X로 벌리기, -X로 모으기 // 오른발: -X로 벌리기, +X로 모으기 (반대) - Vector3 footOffset = Vector3.zero; + HumanBodyBones footBone = endBone == HumanBodyBones.LeftToes ? + HumanBodyBones.LeftFoot : HumanBodyBones.RightFoot; + Transform foot = sourceAnimator.GetBoneTransform(footBone); - // 앞뒤 오프셋 (소스 아바타 기준 Z축) - footOffset += sourceAnimator.transform.forward * footFrontBackOffset; - - // 안쪽/바깥쪽 오프셋 (소스 아바타 기준 X축) - // footInOutOffset > 0: 벌리기, < 0: 모으기 - if (endBone == HumanBodyBones.LeftToes) + if (foot != null) { - // 왼발: +일 때 왼쪽(+X)으로 벌림, -일 때 오른쪽(-X)으로 모음 - footOffset += sourceAnimator.transform.right * footInOutOffset; - } - else // RightToes - { - // 오른발: +일 때 오른쪽(-X)으로 벌림, -일 때 왼쪽(+X)으로 모음 - footOffset -= sourceAnimator.transform.right * footInOutOffset; - } + // 로컬 오프셋 계산 + Vector3 localOffset = Vector3.zero; - targetPosition += footOffset; + // 앞뒤 오프셋 (로컬 Z축) + localOffset.z = footFrontBackOffset; + + // 안쪽/바깥쪽 오프셋 (로컬 X축) + if (endBone == HumanBodyBones.LeftToes) + { + // 왼발: +X로 벌림 + localOffset.x = footInOutOffset; + } + else // RightToes + { + // 오른발: -X로 벌림 + localOffset.x = -footInOutOffset; + } + + // 로컬 오프셋을 월드 좌표로 변환하여 적용 + targetPosition += foot.TransformDirection(localOffset); + } } // 최종 위치와 회전 적용