XR interaction is a toolkit that allows us to perform various touch gestures like tapping, twisting, pinch, and many more. XR interaction gives us better flexibility to give users more control over the virtual object.
We can manipulate any virtual object using the XR interaction. This toolkit builds on the interactor and interactable component set as a core base system.
XR Interaction Toolkit for AR
The AR functionality provides by the XR interaction toolkit includes:
- Gesture system
- Gesture Interactor
This system gives us the flexibility to perform various touch gestures like:
- Elevation (Bonus!)
Above all, this intractable are very useful when the user wants all these gestures to perform on a single virtual object.
XR Interactable Manager
- Create a new Unity 3D project.
- Goto the Windows-> Package Manager and installed the following packages,
- ARFoundation (preview.7 – 4.1.0)
- ARCore XR Plugin (preview.7 – 4.1.0)
- Universal RP (7.4.3)
- XR Interaction Toolkit (Preview – 0.9.4)
- Delete the MainCamera from the Hierarchy.
- Right-click in the Hierarchy Goto XR-> AR Session, this will create an AR Session object in the hierarchy.
- Right-click in the Hierarchy Goto XR-> AR Gesture Interactor, this will create an AR Session Origin and the XR Interaction Manager object in the scene.
- Add the following script to the AR Session Origin object as seen in the below image.
We have done some customization in interactable scripts. In addition, all scripts have some references to attached to it.
We created a separate interactable object to which all the interaction performed on our virtual object. Each virtual object has its own interactable to which it can be manipulated by selecting them at once.
First, you have to select any virtual object to perform any operation on it. Only one virtual object is selected at any given time and performs a single manipulation operation.
We are using the various AR techniques that include:
- Plane Detection
- Object Placement (AR Raycasting)
- Light Estimation
- Object Interaction
- Universal RP
- Real-time shadow
In conclusion, this toolkit helps us to provide an effective technique to handle the virtual object in world space.
Find out the whole project on the GitHub.