tks_yoshinagaの日記

KinectやLeap motion, VRやARなどの技術を使ってやったことのメモとか

Manipulating Objects in MetaQuest (Preparation)

0. Contents of This Article

This article begins by introducing how to manipulate a 3D object (cube) using Meta Quest. However, when it comes to grabbing objects in VR or AR, the required settings vary depending on whether the object is nearby or far away. In this series, we'll cover how to achieve this for each case. As a preparation, this article explains the settings that are common to each case.


*This video is for AR, but it's compatible with both AR and VR.

It should be noted that this article assumes manipulating the cube displayed in VR or AR scenes created with the following links. Since it starts with just viewing the cube in Quest without adding any special components to it, you can achieve object manipulation in other projects by following the content of this article and subsequent articles. (Assumes the use of OVRCameraRigInteraction prefab instead of OVRCameraRig)

[VR Version]

[AR Version]

 

1. Duplicate the Scene

You can edit the scene created in the previous article, but to try object manipulation without breaking it, duplicate the scene. Skip this section if unnecessary.

  • Open the VR or AR scene created in the previous article.
  • Click on File -> Save As...
  • Save the current scene with a new name, e.g., FarManipulation.
  • Make sure that the scene name displayed in the Hierarchy is FarManipulation.

 

2. Enable Object Collision Detection

To grab and manipulate objects, you need to detect collision between hands/controllers and objects. The steps for collision detection with objects explained here are common to Unity development, not limited to Quest.

  • Select the target object (Cube) in the Hierarchy.
  • Ensure that the detailed information of Cube displayed in the Inspector includes BoxCollider. For objects other than Cube, use colliders suitable for each object. For custom models, manually add colliders.
  • Click on the Add Component button at the bottom of the Inspector.
  • Search for Rigidbody in the search area.
  • Select Rigidbody from the displayed options.
  • Confirm that Rigidbody is added to the Inspector, and change as follows:
    Use Gravity: OFF
    Is Kinematic: ON

In short, collision detection requires both Collider and Rigidbody.

 

3. Add Attributes for Grabbing and Manipulation

Here, we add two types of attributes: grabbable and movable.

[Make It Grabbable]

  • Select Cube in the Hierarchy.
  • Click on Add Component and search for Grabbable.
  • Select Grabbable from the options.

[Make It Movable]

  • Click on Add Component in Cube's Inspector.
  • Search for Grab Free.
  • Select One Grab Free Transformer.
    *This script allows detailed settings for single-handed manipulation.
    *You can set constraints on movement and rotation by configuring it.
  • Open Options in Grabbable.
  • Drag and drop Cube onto the area to the right of One Grab Transformer.
    *This action registers One Grab Transformer added to Cube with the Grabbable script, completing the preparation for grabbing and moving the object with one hand.
  • If you want to enable two-handed manipulation, click on Add Component again.
    *Skip this step if single-handed manipulation is sufficient.
  • Select Two Grab Free Transformer.
  • Open Options in Grabbable again.
  • Drag and drop Cube onto the area to the right of Two Grab Transformer.
  • When the dialog box appears, select Two Grab Free Transformer.
    *Currently, Cube has two types of GrabFreeTransformers (One and Two) registered, so this dialog asks which one to use.

     

  • If the options in Grabbable are as follows, it's OK:

     

 

4. Next Steps

With the settings completed to change the position, rotation, and scale of the object (Cube) when grabbed by the controller or hand, we are now ready. However, you still can't manipulate the object yet. This is because, as explained at the beginning, different settings are required for objects and controllers/hands depending on their proximity. Furthermore, settings for whether to use the controller, hand, or both when grabbing have not been made yet. The next article will cover how to set up for each proximity case.

 

[For Nearby Objects]

 

[For Far Objects]

 

5. List of Articles on Meta XR SDK

tks-yoshinaga.hatenablog.com