Oculus Controller Art in Unity
Contribution by Melis Gökalp
This tutorial explains how you can attach controller art as game objects to your XR Rig and have them move/tracked as your controller hands. The controller art could be Oculus game controllers or custom hand objects. The end result will look like this:
You need to have set up an XR Rig using any Unity packages. You can follow the tutorials for any of the SteamVR, OculusSDK or the Unity XR Interaction Toolkit in order to add an XR Rig to your game scene. You can add an XR Rig like below:
2. Download the latest version of Oculus Controller Art.
3. Unzip the downloaded file and choose the controller folder for your device such as "Oculus Touch for Quest 2".
4. Import that folder to your project. You can also drag the folder into the Unity project screen.
5. Drag any of the controller prefabs to your scene such as "quest2_controllers_div2". Do this two times because we will need one game object for each controller.
6. Right click the "quest2_controllers_div2" prefab and choose "Unpack prefab" like below. Do this for both prefabs.
7. Then drag one prefab for each controller object under the XR Rig. Then make sure that the left controller has only "left_quest2_controller_world" and "left_quest2_mesh" attached to the prefab. Same applies for the right controller hierarchy, you only need to have "right_quest2_controller_world" and "right_quest2_mesh". The final hierarchy of game objects under your XR Rig and controllers should look like this:
8. Make sure that your LeftHand Controller and RightHand Controller objects have Tracked Pose Drivers or an equivalent script to get the controller pose from appropriate left or right Generic XR controller. This way, your game objects with controller art will follow the controller movement and poses in the game.
9. This can be used any custom controller object! You can use even use lightsabers and robot hands.
If your game controller objects are falling to the ground and not moving with your controllers, check if you have the Tracked Pose Driver set correctly and if the controllers are under another game object. This is important because the each controller object with a mesh should be attached to a game object in order to be tracked. Also ensure that there isn't any Rigidbody component with mass attached to the controller, which would make it fall due to gravity.
If the controller objects do not have a mesh/colors, make sure to that you have the mesh imported and attached to the controller object.