XR Interactor and XR Interactable Troubleshooting

Hi

I've just spent ages trying to get my XR Interactors and XR Interactables working together nicely in my Oculus Quest 2 game so I thought I'd post some of the gotchas that had me stumped for hours in case it helps anyone else...

  • On the Oculus Quest 2, I found I had to create an XR -> Device Based -> Direct Interactor / Ray Interactor, not an XR -> Direct Interactor / Ray Interactor. (maybe I was doing something wrong)
  • My XR Ray Interactor was not registering collisions with my XR Grab Interactable because I had the collision component on the XR Grab Interactable set to be a trigger. I was able to get it working by ticking on Raycast Trigger Interaction in the XR Ray Interactor
  • If you don't have an XR Interaction Manager in your scene your XR interactions will not work. You need to add one and then put it into the empty slot in any of your XR Interactors or XR Interactables (new ones of these you create will find it automatically)
  • If you XR Direct Interactor isn't working, check it has a collision component attached to it (you probably want a trigger)
  • If your XR Grab Interactable item is not working, make sure you add an item to its list of colliders and drag a collider into the list
  • A good way to help debugging is to create a sphere attached to your hand controller and another one attached to the grabbable, with the same radii as the colliders on them, with alpha'd textures, so you can see when they're meant to be intersecting. You could also set audio and/or haptic feedback events on your interactors for when they go into hover. You could also set hover enter and leave events on your interactables to change the debug sphere material from, say, alpha'd pink to alpha'd yellow, and then back again.

Hope this helps someone, and if something I've posted here is actually wrong, please set me straight and I'll learn something too ;)

12 Likes

Thank you !

If only Unity could be bothered to produce adequate documentation !

5 Likes

Thank you! This solved a pain issue I was having and imagine others will run into.

The default rig uses rays by default and removing those to add direct interaction doesn't work as Unity's own course on Learn describes. If you want a collider it has to be added to the same game object as the XR Controller and cannot be a child object. Adding the from the XR create object showed the pattern that worked.

1 Like

THANK YOU FOR THIS! I was completely lost, and thanks to this post I re-did my (now Device Based) Direct interactors. I copied all the childs from my originals, added the missing scripts and have them working!! Thanks again!!

better documentation than unity

1 Like

For Oculus 2 a Device Based Interactor should be attached to each controller.

In my case, there was an Event System with a blue megaphone icon enabled, I disabled it and enabled "XRUI Input Module (script)" in my "EventSystem" game object.

The Grab Interactable fix helped me! Thanks a million!

For me it was making a canvas for my UI without including a Tracked Device Graphical Raycaster

I cannot get this to work. I mean I can grab objects and release them. But I want some script to run when released. I added a canvas with some text and in every single Interactable event I set the canvas text to a text describing the event hover entered, hover exited, Selected Entered and all of them. To see the text on the canvas change whenever i trouch the object with controllers or hands. But nothing happens. Also I can't select a method in the script I added to the object (then i could just have printed some messages to the console). Anyway Does anyone know what needs to be linked together and set? Things must be set up correct when objects can be grabbed and released, just somehow the events are not triggered.
I tried to follow this guide: https://fistfullofshrimp.com/how-to-unity-vr-basics-2023-grabbing-objects/