skyf의 게임 개발기
[개발] 2021.06.01(화) - 손목IK - 컨트롤러 회전 싱크 본문
VRIK를 이용해 모델의 손을 컨트롤러의 위치에 시키고 회전 시켜주는 기능을 구현 중에 난관이 있었지만 해결 되었다.
원인은 모델마다 팔을 벌린 정도도 다르다 보니 기존 T포즈 형태의 모델 기준에서 했던 방식이 안통했던 것이다.
그래서 위와 같이 핸드의 월드Rotation을 0,0,0으로 돌린 뒤에(위 사진 처럼) 그 기준에서 왼손 오른손이 돌아가야할 방향을 코드상에서 직접 돌려주었다.
case IKBoneType.LeftHand:
{
if(modelType == ModelType.Mixamo)
transform.localRotation = (Quaternion.Euler(offset_handWrist_vertical, offset_handWrist_horizontal, 0)) * (Quaternion.Euler(-90, 90, 0)) * targetQ;
else
{
boneTr.rotation = Quaternion.identity;
targetQ = Quaternion.Euler(90, 90, 0) * boneTr.rotation;
transform.localRotation = targetQ;
}
}
break;
case IKBoneType.RightHand:
{
if (modelType == ModelType.Mixamo)
transform.localRotation = (Quaternion.Euler(offset_handWrist_vertical, -offset_handWrist_horizontal, 0)) * (Quaternion.Euler(-90, -90, 0)) * targetQ;
else
{
boneTr.rotation = Quaternion.identity;
targetQ = Quaternion.Euler(-90, 0, 90) * boneTr.rotation;
transform.localRotation = targetQ;
}
}
break;
'Unity > Unity 개발 일지' 카테고리의 다른 글
[개발]2021.06.02(수) - ForeArmTwist (0) | 2021.06.02 |
---|---|
[개발]2021.06.02(수) - VR 풀바디 설정 플로우 (0) | 2021.06.02 |
[개발] 2021.05.30(일) - 앞으로의 연구 계획 (0) | 2021.05.31 |
[개발] 2021.05.30(일) - 쓰레드 관련 (0) | 2021.05.30 |
[개발] 2021.05.28(금) (0) | 2021.05.28 |