I found a solution for this that works for me!
Make a new C# script with the following code and use it instead of the usual XRGrabInteractable.cs component.
Just be sure to set Movement Type field to Instantaneous and add the Attach Transform.
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
public class XRGrabInteractableFixedAttachTransform : XRGrabInteractable
{
private bool isGrabbed = false;
protected override void OnSelectEntered(SelectEnterEventArgs args)
{
isGrabbed = true;
base.OnSelectEntered(args);
}
protected override void OnSelectExited(SelectExitEventArgs args)
{
isGrabbed = false;
base.OnSelectExited(args);
}
public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
{
base.ProcessInteractable(updatePhase);
if (isGrabbed && movementType == MovementType.Instantaneous)
{
var attachOffset = transform.position - attachTransform.position;
transform.position = selectingInteractor.transform.position + attachOffset;
transform.rotation = Quaternion.Inverse(Quaternion.Inverse(transform.rotation) * attachTransform.rotation * Quaternion.Inverse(selectingInteractor.transform.rotation));
}
}
}
This fix works with:
XR Interaction Toolkit 1.0.0-pre.3
It may not work with earlier versions due to renaming of the OnSelectEntered & OnSelectExited methods but it’s just a matter of using the correct names for earlier version of the XRITK.