Unity VR: Determine the Grab Point
Intro
Our Right Hand Controller has a Direct Interactor, which allows your virtual hands (or controller models) to directly interact with nearby Grab Interactable Objects, rather than using a ray or pointer.
But, we want to make sure the Direct Interactor has the ability to override the Ray Interactor when they both can interact with the same Grab Interactable. On the Ray Interactor we want to set the Raycast Mask to the Interaction Layer Mask of the Grab Interactable objects. The Raycast Mask filters which objects the ray can “see” and interact with. When the ray is emitted, Unity checks what it hits — but only objects on layers included in this mask will be considered valid targets for interaction. By default the Raycast Mask is set to Everything, so Interaction Manager processes Interactors in a certain order and Ray Interactor may “win” because the Raycast is highlighting/selecting every layer other, consuming input (like grip or trigger) before the Direct Interactor can.
Make sure there is an XR Interaction Group added to the Controller, which manages interactor priorities (so one can override the other). Assign both the Direct and Ray Interactors to the list (usually Direct goes first).In the Override Configuration, make sure the Direct Interactor comes first in the list (priority order matters!), along with giving the Direct Interactor Can Override the Ray Interactor.
An issue with this is how the Director Interactor interacts with the Grab Interactable Object when triggered, it uses the origin of the Grab Interactable Object as the attachment points to the hand controller (Direct Interactor). This creates the visual of the controller hand snapping through the model (basketball), and attaching to the center of the Grab Interactable’s collider, instead of the point of where it was grabbed.
Dynamic Attach
The Dynamic Attach overrides this preset position and rotation relative to the interactor (using the Attach Transform)by letting the object stay in place when grabbed — it grabs where it was touched, not where you defined it to go.
When you turn on Dynamic Attach, the rest of its sub-properties will be turned and it should work right out of the box
Just a reminder to put your Interactables on a different layer than the XR Origin and have those two layers ignore each other in the Physics Matrix, and change the Interaction Layer Mask on the Grab Interactable set to the same Layer as your Direct/Ray Interactor. Just note that object Layer and Interaction Layer Mask are different. The Object Layer affects physics and the Interaction Layer Mask affects interactions with Interactors using the XRI toolkit.
Conclusion
Using Dynamic Attach is a great way to make object interactions in VR feel more natural and immersive. Instead of snapping to a fixed position, the object is grabbed right where the user touches it — just like in real life.