version 2.0.1
If turn off TrackRotation, the XRGrabInteractable will work weird.
see Line 535 in XRGrabInteractable.cs:
return interactorAttachTransform.position + transform.TransformDirection(m_InteractorLocalPosition);
Shouldn’t use transform.TransformDirection(m_InteractorLocalPosition)
here because m_InteractorLocalPosition
is not related to transform
, using transform
here is meaningless.
The correction is to replace transform.TransformDirection(m_InteractorLocalPosition)
with GetAttatchTransform(interactor).TransformDirection(m_InteractorLocalPosition)
.
The whole method should be corrected like below:
Vector3 GetWorldAttachPosition(IXRInteractor interactor)
{
var interactorAttachTransform = interactor.GetAttachTransform(this);
if (!m_TrackRotation)
return interactorAttachTransform.position +
GetAttatchTransform(interactor).TransformDirection(m_InteractorLocalPosition);
// the following is replaced: transform.TransformDirection(m_InteractorLocalPosition);
return interactorAttachTransform.position + interactorAttachTransform.rotation * m_InteractorLocalPosition;
}