Ray Interactor in Unity
While working in Unity VR, you will come across a variety of interactors and interactables. Interactables are objects you can interact with in VR, while interactors let the user interact with interactables. For this article, I will just be covering interactables, specifically the Ray Interactor. Let’s dive in!
Controllers
The starter asset hand controllers come with a host of components attached, including the XR Controller, XR Ray Interactor, Line Renderer, XR Interactor Line Visual, a Sorting Group and a Material for the line.
XR Ray Interactor
The Ray Interactor is used to interact with objects from a distance, and the line renderer gives the player a visual cue of where the Ray Interactor is shooting. As you can see, it is working with the XR Interaction Manager and offers an assortment of changeable values.
The Interaction Layer Mask can be used to determine which interactables the Ray Interactor can detect.
Enable Interaction with UI Objects can be enabled with a tick-box, and Force Grab will move the object to your hand rather than interacting from a distance.
The Raycast Configuration is where you can set your line to be straight or curved, as well as the Distance it will project.
The Line Renderer component is where you can change the base color and other settings on your Raycast visual, and both the XR Ray Interactor and the Line Renderer work with the XR Interactor Line Visual.
The XR Interactor Line Visual component offers more color choices depending on the type of interaction.
Here are the basic Ray Interactors at work on both controllers.
I will go deeper into these components in following articles, but that is all for now! Please join me in my next article where I get the player moving with Locomotion in VR. Have a great day and thanks for reading!