Create your reality

Previously we saw how to set up a Unity project to work with the Oculus Passthrough API. If you haven’t checked out the first part of this series, we highly recommend checking it out as the API will not work without the correct setting.

In this blog, we’ll learn how to develop a scene implementing AR with passthrough. We’ll see the different components that are required for passthrough, set up the camera rig, and finally create an augmented interactable object. So let's begin!

Adding Passthrough Feature and Scene Setup

In this section, we’ll see all the components that we require in order to make the Passthrough work and set up our scene as well.

  • In the Project window, navigate to Scenes → Open the SampleScene.

  • Delete the Main Camera from the Hierarchy window.

  • Search for OVRCameraRig in the Project window → drag and drop it in the Hierarchy

    OVRCameraRig

  • Select the OVRCameraRig GameObject → under the OVR Management component, click on the General tab and make sure the Passthrough Capabilities is checked ✅ → scroll down and make sure the Enable Passthrough is also checked ✅

    Enable Passthrough Capabilities

  • Next, add the OVR Passthrough Layer component to it and select the Placement as Underlay from the dropdown.

    OVR Passthrough Layer

  • Let’s create a 3D cube by right-clicking on the Hierarchy window → select 3D objectsCube.
    Adjust its scale to 0.5 units in all directions so that it’s not too big. Also, change its position such that it's slightly ahead of the Camera.

    3D game object

  • Now, if you hit play and test it, you will not be able to see the passthrough feature working. Can you guess why? Well, that's because we need to get rid of the skybox and to do that:

    • Click on WindowRenderingLighting.
    • Select the Environment tab → select the Skybox Material as None.

    Skybox Material

  • Now you can hit play and test the scene. You should be able to see the cube floating in your physical environment.

    testing

Allowing Interaction

In this section, we’ll add a few more components/prefabs to the scene. After which we’ll have VR controllers that can interact with the cube.

Adding VR Controllers

  • Open the OVRCameraRig prefab by clicking on it while holding the Alt key to view its children.
  • In the Project Window, search for OVRControllerPrefab → first drag and drop it on the LeftHandAnchor GameObject and then again on the RightHandAnchor GameObject.
  • Select the OVRControllerPrefab under LeftHandAnchor GameObject and select the Controller as L Touch from the drop-down.
  • Next, select the OVRControllerPrefab under RightHandAnchor GameObject and select the Controller as R Touch from the drop-down.

    Adding VR Controller

Adding Grab Feature to VR Controllers

  • Select the LeftHandAnchor GameObject → add the component OVR Grabber.

  • A Rigidbody component gets added automatically, uncheck the Gravity parameter and check the Is Kinematic from that component

  • For the OVR Grabber component, drag and drop the LeftHandAnchor GameObject into the Grip Transform parameter. Then, select the Controller as L Touch from the drop-down.

  • Add a Spherical Collider and change its Radius to 0.05 so that the collider just surrounds the controller.

    *Adding Grab Feature

  • For the RightHandAnchor GameObject, follow the same steps above to add the grab feature. But, for the OVR Grabber component, drag and drop the RightHandAnchor GameObject into the Grip Transform parameter. Then, select the Controller as R Touch from the drop-down.

    OVR Grabber

Making the Cube Grabbable

  • Select the Cube and add the OVR Grabbable component.
  • Add Rigidbodycomponent → uncheck the Gravity parameter.

    OVR Grabbable

Now you can test the scene by playing the press button.

testing

Conclusion

So we have seen how you can add GameObject to the scene and make it interactable. This is just the beginning of the journey to work with mixed reality. There are many other features that you can use to create different experiences. In the next blog, we’ll see how we can customize the Passthrough filter.

________________

Thank you

Thanks for reading this blog post. 🧡 If you are interested in creating your own AR and VR apps, you can learn more about it here on immersive insiders. Also, if you have any questions, don't hesitate to reach out! We're always happy to help.

You’ve successfully subscribed to immersive insiders
Welcome back! You’ve successfully signed in.
Great! You’ve successfully signed up.
Your link has expired
Success! Check your email for magic link to sign-in.