Search Unity

Feature Request RayInteractor to handle only the closest target as valid

Discussion in 'XR Interaction Toolkit and Input' started by Firewalker, Dec 7, 2020.

  1. Firewalker

    Firewalker

    Joined:
    Mar 30, 2012
    Posts:
    39
    We needed to do a simple tweak of the RayInteractor in order to correctly emit Hover messages.

    Case:
    If there are more targets hovering the ray, messages are not sent to already hovered targets when hover is lost from the closest target. Example: Object is on the floor. The floor receives onhover once the ray moves across the floor. Then ray crosses the object. The object receives, onhover, but the floor is still on the path of the ray. Once the ray moves away from the object but remains on the floor, the floor never receives new onhover, as flor is still in the validTargets list.

    Solution:
    Create a toggle that will enable RayInteractor to communicate only to the closest target.

    Code (CSharp):
    1.                 if (validTargets.Count > 0)
    2.                 {
    3.                     var theone = validTargets[0];
    4.                     validTargets.Clear();
    5.                     validTargets.Add(theone);
    6.                 }
    This code goes to XRRayInteractor.cs on the end of
    public override void GetValidTargets(List<XRBaseInteractable> validTargets)

    It would probably save a lot of people's lives and hours. Thank you.
     
  2. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    335
    Hi @Firewalker, if you haven't already can you post this in our public roadmap as feedback so the team can properly track in our planning? Thanks!
     
  3. Firewalker

    Firewalker

    Joined:
    Mar 30, 2012
    Posts:
    39
    Just did. Thanks.
     
    mfuad likes this.