Yet another positioning bug. ![]()
Using pre5 with default attach point compatibility mode.
If the interactable has an attach transform set, and track rotation = off, grabbing this item will result in weird positioning. When rotating the interactor, the interactable rotates around it, meaning the attach point is wrongly calculated to a fixed local position on the interactor.
Original code:
Vector3 GetWorldAttachPosition(XRBaseInteractor interactor)
{
return interactor.attachTransform.position + interactor.attachTransform.rotation * m_InteractorLocalPosition;
}
The code for m_InteractorLocalPosition says:
// Point we are attaching to on this Interactable (in Interactor's attach coordinate space)
Vector3 m_InteractorLocalPosition;
so I woud have changed the method to do this:
return interactor.attachTransform.TransformPoint(m_InteractorLocalPosition);
But that doesn’t work, so something is obviously wrong with m_InteractorLocalPosition. I just brute-forced what it should be from original values and it works, but don’t play supernice with the rest of the system:
Vector3 GetWorldAttachPosition(XRBaseInteractor interactor) {
if (m_AttachTransform != null) {
var deltaPositionInWorldSpace = attachTransform.TransformDirection(attachTransform.localPosition);
var deltaPositionInInteractorLocalSpace = interactor.attachTransform.InverseTransformDirection(-deltaPositionInWorldSpace);
return interactor.attachTransform.TransformPoint(deltaPositionInInteractorLocalSpace);
}
else {
return interactor.attachTransform.position;
}
}
I hope they fix the real problem when solving this. I’m not spending more time on this, because I have a feeling it’s a rabbit hole.