Find the Item(s) That An Interactor Is Hovering On

Is there a way to find the item that an interactor is hovering on? I see the GetHoverTargets method on the XRBaseInteractor class, but it doesn’t appear fully implemented (or I simply can’t figure out how to use it)? Is there some other way. What am I missing?

XR Interaction Toolkit v 0.10

1 Like

Any progress on this? Having the same issue.

The XRBaseInteractor has a GetHoverTargets method that you can call to get the list of all Interactables it is hovering over. In your class, you can do something like:

List<XRBaseInteractable> m_HoverTargetList = new List<XRBaseInteractable>();

void YourMethod()
{
    // Assuming you have a reference to an interactor
    interactor.GetValidTargets(m_HoverTargetList);
    foreach (var interactable in m_HoverTargetList)
        // Do something with the interactable
}

The XRBaseInteractable also has a hoveringInteractors list that contains all of the Interactors that is hovering over it.

You can also add listeners to the public events on Interactor/Interactable when entering or exiting the Hover state so you get notified when it changes.