[OpenXR] Two Hand Grab (XR Interaction Toolkit 2.4.3)
VR/XR Interaction Toolkit 2024. 1. 2. 18:21
https://youtube.com/playlist?list=PLTFRwWXfOIYBIPKhWi-ZO_ITXqtNuqj6j&si=XhyHS26tNDP6u7CA
XR Interaction Toolkit 2.4.3
XR Interaction Toolkit 2.4.3 OpenXR Oculus
www.youtube.com
새 씬을 만들고 메인 카메라를 지운후 XR Origin을 생성 합니다.

Left / Right Controller를 선택후 XR Controller를 제외한 나머지 컴포넌트를 지웁니다.


다음과 같은 구조로 만들어 주고

핸드 프리팹을 Offset으로 가져옵니다.

왼손, 오른손의 Offset의 회전을 설정 합니다.


Left/Right Controller를 선택해

Model Prefab을 None으로 설정 합니다.

실행후 결과를 확인 합니다.
인터렉터 설정
Direct Interactor를 검색해

Left, Right Controller자식으로 넣어 줍니다.

Direct Interactor들을 선택해

햅틱 이벤트는 꺼줍시다 (베터리 절약)

Sphere Collider 컴포넌트의 Radius의 값은 0.1로 설정 합니다.


빈오브젝트(Rifle)를 만들고

다음과 같은 구조로 만든후 라이플 프리팹을 넣어 줍니다.

기본으로 부착 되어 있는 스크립트를 제거 하고 사이즈와 회전각을 조절해 다음과 같이 설정 합니다.



라이플을 선택 하고 Rigidbody와 XR Grab Interactable컴포넌트를 부착 합니다.


라이플 메쉬 콜라이더의 Convex 속성을 체크 합니다.

플레이 후 결과를 확인 합니다.
위와 같이 둥둥 떠다닌다면
리지드 바디의 Is Kinematic을 체크 하거나

Throw On Detach를 체크 해제 하면 됩니다.

콜라이더 포지션으로 잡혀 있기 때문에

잡았을경우 Direct Interactor의 위치가 콜라이더 포지션으로 마춰 집니다.

만약 Direct Interactor의 위치를 수정 하고 다시 테스트 해보면



다음과 같이 동일하게 작동 한다는것을 알수 있습니다

Direct Interactor의 위치를 원래대로 해놓고



다음 단계를 진행 합니다.
Rifle을 선택 한 후 빈오브젝트를 만들고 그 아래 Sphere를 생성하고 Collider는 제거 합니다.


XR Grab Interactable의 Attach Transform 속성에 넣어 봅니다.

다시 실행후 결과를 확인 하면 그랩 위치가 Attach Point로 마춰진다는것을 확인 합니다.
이때 우리의 Select Mode는 기본속성인 Single인것도 같이 확인 합니다.

Attach Point를 복사 합니다.

위치를 설정 하고

Select Mode를 Multiple로 변경하고

Secondary Attach Transform에 넣어 줍니다.

실행후 결과를 확인 합니다.
이때 두번째 잡은 손은 앞뒤로 첫번째 잡은 손은 좌우로 움직이며 물체가 회전 한다는것을 확인 합니다.
이것은 Add Default Grab Transformers가 체크 되어 있기 때문에

XR General Grab Transformer 컴포넌트가 자동을 부착 되며

다음 프로퍼티에 추가 됩니다.

이때 Two Handed Rotation Mode의 설정이 First Hand Directed Towards Second Hand 로 되어 있기 때문입니다.

첫 번째 손을 사용하여 양손 회전을 결정한 다음 두 번째 손을 향해 개체의 방향을 지정합니다.
Enum XRGeneralGrabTransformer.TwoHandedRotationMode | XR Interaction Toolkit | 2.4.3
Two handed rotation mode. Assembly : solution.dll public enum TwoHandedRotationMode Fields Name Description Value FirstHandOnly Determines rotation using only first hand. 0 FirstHandDirectedTowardsSecondHand Determines two handed rotation using first hand
docs.unity3d.com
이외 다른 옵션은 다음과 같으며
FirstHandOnly | Determines rotation using only first hand. | 0 |
FirstHandDirectedTowardsSecondHand | Determines two handed rotation using first hand and then directing the object towards the second one. | 1 |
TwoHandedAverage | Directs first hand towards second hand, but uses the two handed average to determine the base rotation. |
각 손을 고정 시키는 방법은 제공 하지 않습니다.
대안은 무엇인가?
'VR > XR Interaction Toolkit' 카테고리의 다른 글
[OpenXR] XR Slot Interactor (2024-01-03방송분) (0) | 2024.01.03 |
---|---|
[OpenXR] XRGrabInteractable (Kinematic/Instantaneous/Velocity Tracked) (0) | 2024.01.03 |
XR-Interaction-Toolkit-Examples (0) | 2024.01.02 |
[OpenXR] Grab transformers / XR Interaction Toolkit 2.4.3 (0) | 2024.01.02 |
[OpenXR] When using Two Hand Grab in XR Interaction Toolkit 2.4.3 (0) | 2024.01.02 |