Oculus Interaction SDKを使ってみました

Oculus Interaction SDKを使う設定を備忘録としてまとめておきます。

:::note warn
Oculus Integration V46の設定となります。
また、Unityプロジェクト作成の詳細は、本題ではないので省きます。
XR Plug-in Managementがインストール済みで、Quest向けの設定をしてあることが前提となります
:::

# Oculus Integrationの導入
1. Oculus Integrationのインポート
全てのパッケージをインポートします
![1-OculusIntegration.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/d2170d59-ba33-682f-8e2d-0ccbd7e8f892.png)
![2-OculusIntegration.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/7b5480e6-2fdd-43ec-9e5d-3bc3d2c32474.png)
1. インポート中の選択肢
![3-OculusIntegration.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/9198aa52-ea47-d257-6852-9c59b97c0c7c.png)
![4-OculusIntegration.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/374211aa-22b4-0bc7-d648-122d90dfb83d.png)
![5-OculusIntegration.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/e2bbe752-43c6-77c2-dd11-5302caccf200.png)
![6-OculusIntegration.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/f73bdf06-3bc0-c763-836f-056e872c447b.png)
![7-OculusIntegration.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/44af7cf9-43b0-a1ef-c48f-2e95722af3c3.png)
1. OculusProjectConfigのHandTrackingSupportをControllers And Handsに変更します
![8-OculusIntegration.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/f0143b3b-7b07-e580-9024-35557c1cd54d.png)


# シーンの準備
## 掴む側
1. Main Cameraを削除して、OVRCameraRigを追加します
![8-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/a60578ef-703a-366c-e42a-4ff6ab95dd14.png)
1. OVRHandPrefabをLeftHandAnchorとRightHandAnchorに配置します![9-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/4a00cd6a-4fb8-964c-e2d4-0816f45d8eb3.png)
1. RightHandAnchorに配置したOVRHandPrefabを右手用に修正します
![10-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/deb1e154-3f60-fbc4-fde7-91a886aa20d3.png)
1. LeftHandAnchorとRightHandAnchorに追加したOVRHandPrefabから以下のコンポーネントを削除します
    * OVRSkeletonRenderer
    * OVRMesh
    * OVRMeshRenderer
    * SkinnedMeshRenderer
![11-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/41a87d83-c654-336c-6bc5-a520fb4a0f85.png)
1. OVRControllerPrefabをLeftControllerAnchorとRightControllerAnchorに配置します
![22-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/444dbe92-a783-5c17-7199-6fb954e86eeb.png)
1. 追加したOVRControllerPrefabのControllerの左右をそれぞれL Touch、R Touchに設定します
![23-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/52eb31e2-c590-d5d6-e886-7bca20b161b0.png)
1. OVRInteractionを追加します![12-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/45e69de5-3c69-5c27-6e27-af3f564261d3.png)
1. OVRInteractionにOVRCameraRigを設定します
![13-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/3eb4f3bb-c5d9-d29c-1ca1-346ffa356c3a.png)
### 手の設定
1. OVRInteractionにOVRHandsを追加します
![14-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/19cfee0b-4d79-81fb-b21b-5256de5f0259.png)
1. OVRHandsのLeftHand、RightHandの配下にあるHandFeatuersにOVRInteractionを設定します
![15-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/98c40c17-4467-f624-8347-f914ce16935c.png)
1. OVRHandsのLeftHand、RightHandの配下にあるOVRHandDataSourceにOVRInteractionとOVRHmdを設定します
![16-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/d589c150-d2f4-c940-17ce-135d71bcef93.png)
1. OVRHandsのLeftHand、RightHandの配下にあるHandInteractorsLeft、HandInteractorsRightにHandGrabInteractorを追加します
![17-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/18b80b03-4d26-a30b-0720-a0f057a5983d.png)
1. OVRHandsのLeftHand、RightHandの配下にあるHandGrabInteractorにそれぞれ、LeftHand、RightHandを設定します
![18-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/28fc0ba9-5924-ed2a-2046-493a5ba8fccd.png)
1. OVRHandsのLeftHand、RightHandの配下にあるHandInteractorsLeft、HandInteractorsRightにそれぞれのHandGrabInteractorを設定します
![19-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/502c4416-0754-d593-894c-de4fddc831b5.png)
### コントローラーの設定
1. OVRInteractionにOVRControllersを追加します
![20-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/b1909442-6764-b202-e46f-512fa92e3b8f.png)
1. OVRControllersのLeftController、RightControllerの配下にあるOVRControllerDataSourceにOVRInteractionとOVRHmdを設定します
![21-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/c30a5419-dca4-e71c-a12c-140e1e3d5cdc.png)
1. OVRControllersのLeftController、RightControllerの配下にあるControllerInteractorsにControllerGrabInteractorを追加します
![24-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/e2698191-9d01-bda4-d625-0d32495c1f8b.png)
1. OVRControllersのLeftController、RightControllerの配下にあるControllerGrabInteractorにそれぞれ、LeftController、RightControllerを設定します
![25-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/ad646a62-0917-42fa-c372-794be3da3a51.png)
1. OVRControllersのLeftController、RightControllerの配下にあるControllerInteractorsにそれぞれのControllerGrabInteractorを設定します
![26-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/4ef837de-814f-cad3-c21f-a1e5c1d88a59.png)

## 掴まれる側
1. 空のオブジェクトを作成し、以下のコンポーネントをアタッチします
    * Grabbable
    * Rigidbody
    * PhysicsGrabbable
![30-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/f88baeca-8660-5e3e-2669-0ee9f418d736.png)
1. 空のオブジェクトにCylinderを追加します
![31-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/bebbbd8d-71ae-7300-e188-432d08632c7b.png)
1. CylinderにHandGrabInteractableをアタッチします
![32-Scene.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2729904/8d59eeec-fced-405a-4189-120dda04a5cd.png)

これで、掴むことができるようになりました。