XR Controller (XR Ray Interactor) rotation and position offset?

I cant seem to find a way to offset the native rotation of my XR controller. Its not a big deal for the direct Interactor since i can rotate the controller Model and move the Transform. However for the XR Ray Interactor, no matter how my Hand model is rotated, the ray always shoots out from a (atleast for me with the Index controller) very uncomfortable angle.

Ive added an illustration to explain what i mean:

alt text

The Ray interactor always hast to be attached to the same GameObject as the XR Controller so i cant just add the Interactor as a Child to the GameObject.

I’m not too sure if you managed to solve this at all or anything. But I managed to find out a way to change the position of where the Raycast starts. I went through the XRRayInteractor script and found a transform variable that was used called “startTransform” which is then referenced to the Original Attach Transform. Which is the instanced empty GameObject called “[Controller] Original Attach” by moving this object it changes where the Raycast originates from. (Extra note, the OriginalAttachTransform also copies the AttachTransform reference after interacting with an object. So by setting that, it’ll set the Original Attach Transform by default)

Which is the object that I have selected in the screenshot below:
177401-unity-yobhrichbi.png

I hope this helps you out and anyone else that finds this thread!

If anyone still needs a solution for this, create an empty with your desire transform(position and rotation, then use it in the Attach Transform field of the XR Ray Interactor.188400-untitled.png .

I have discovered a solution to this issue:


  1. Remove the XR Ray interactor, Line Renderer, and XR Interactor Line Visual components from the controller object.

  1. Create an empty gameobject as a child of the controller, and name it appropriately (RayInteractorOrigin or whatever).

  1. Add the XR Ray Interactor, Line Renderer, and XR Interactor Line Visual components to the child. DO NOT add an XR Controller component. This will be handled by the XR controller object in the parent object.

  1. The interactor Raycasts will now originate from the new object. No need to use Attach Transforms.

Quick note: The Raycast will point towards vector3.forward (the X (Blue) Axis) of the RayInteractorOrigin Object. You’ll need to rotate the object accordingly so it points the way you want.

Did you figure this out? I am also trying to offset the ray but cant figure out how - without using a hackish workaround. At runtime an gameobject called “original attach” is added under the controller. This is the object used to offset the ray.

okay so there is a very dumb way of fixing this, and I fully would appreciate if someone found a better way. But the way I did it was to create a script on an empty object that on Start() does a GameObject.Find on the Attach and Original Attach objects, uses GetComponent-Transform()-.rotation to get the rotation and sets it manually. It ain’t pretty, but it works! Also you should remember for this that the Euler function has a weird order of z,x,y so make sure if you take a Vector3 input to switch the numbers around before applying them as the rotation. It’s stupid but it works!