XR Step-by-Step 2023! Meta Quest: Grab, Tractor Beam and Yeeting! Unity 2022 + Open XR + XR Interaction Toolkit

Virtual and Augmented Reality together are now referred to as XR or “Extended-Reality”.
You’re in the right place at the right time to build something amazing in XR!
XR applications can be created in Unity for many devices, our focus will be on Microsoft Hololens 2 and the Meta Quest

In this blog post series we will focus on Meta Quest!

Check out other blog articles in this (and other) series!
Quick links to Lance’s latest XR Step-by-Step blog articles by device

We have our controllers ready to go! If not, see the previous blog article in this series. Let’s start grabbing and throwing things around 🙂

Full Step-by-Step Instructions!

Goals…

  1. What is an Interactor? What is an Interactable?
  2. Add Interactors to Controllers
  3. Create Interactables

Download the finished code for this blog article @ Github Repo

What is an Interactor? What is an Interactable?

  • Interactor: Very simply, an Interactor is the thing performing an interaction in the virtual world, like your controller or your virtual hand.
  • Interactable: An Interactable is what the Interactor interacts with. Like a ball or a button that can be pushed, thrown, or otherwise interacted with.

Add Interactors to Controllers

  • XR Interaction Toolkit as it’s core was created to make it easy for XR developers to make rich experiences, and at the heart of those experiences is enabling the user to interact with their virtual environment.
  • We will be adding close grabbing interactor ability to our right controller, and enabling far away grabbing interactor ability in our left controller (think tractor beam from Star Wars).
  • We will start by removing the default line interactors from the Right controller
  1. (Hierarchy) Expand XR Origin (XR Rig) -> Click Right Controller
  2. (Inspector) Within XR Ray Interactor -> Click the vertical “…” icon
  3. Click Remove Component
  1. (Inspector) Within XR Interactor Line Visual -> Click the vertical “…” icon
  2. Click Remove Component
  1. (Inspector) Within Line Renderer -> Click the vertical “…” icon
  2. Click Remove Component
  • Ok, we removed what we needed to – now let’s make the Right controller into a Grab Interactor.
  • We need to add the XR Direct Interactor and a Sphere Collider.
    • The Sphere Collider sets a spherical area within which objects can be grabbed, it’s too big by default – so we’ll make it smaller. Think of it as a sphere around your hand, if the object is within that area you can interact with it.
  1. (Hierarchy) Click Add Component
  2. (Add Component Search) Type XR Direct
  3. Click XR Direct Interact
  1. (Hierarchy) Click Add Component
  2. (Add Component Search) Type Sphere
  3. Click Sphere Collider

Create Interactables

  • We’ll create a “table” on which we’ll place objects.
  1. (Hierarchy) Right-Click
  2. Click 3D Objects
  3. Click Cube -> Rename it Table
  1. (Hierarchy) Click Table
  2. (Inspector) Change the Transform values (in image below)
  3. (Project) Click Materials folder
  4. Drag Blue onto the Table cube
    • Note, if you didn’t create a Blue before when we were coloring the controller – refer back to that article on how to create a Material
  1. (Hierarchy) Right-Click
  2. Click XR
  3. Click Grab Interactable -> Rename it Grab Cube
  1. (Hierarchy) Click Grab Cube
  2. (Inspector) Change Transform values
  1. (Inspector) Expand XR Grab Interactable
  2. Click Movement Type
  3. Click Velocity Tracking
    • There are a couple different Movement Type choices, but Velocity Tracking is generally the best choice – but feel free to make several cubes and try them all 🙂
  1. Build and Run
    • Awesome! If you put your Right controller close to the cube and click the Grab button (NOT the Trigger button) you grab the cube!
    • If you release the Grab button, it drops.
    • If you aim the laser from your Left controller at the cube and click the Grab button, it tractor beams to your hand!!
    • If you grab the cube and make a throwing motion and release the Grab button you Yeet it! 🙂

I always love feedback and suggestions for new XR / AI blog posts!

Go build something amazing in XR & AI! — Lance 🙂

Check out other blog articles in this (and other) series!
Quick links to Lance’s latest XR Step-by-Step blog articles by device

One thought on “XR Step-by-Step 2023! Meta Quest: Grab, Tractor Beam and Yeeting! Unity 2022 + Open XR + XR Interaction Toolkit”

Leave a Reply