Search Unity

Question Oculus Quest / Interaction SDK : Get click world position ?

Discussion in 'VR' started by hyorange, Jun 7, 2022.

  1. hyorange

    hyorange

    Joined:
    Feb 7, 2022
    Posts:
    4
    Hello.
    I'm using the recent Interaction SDK from Oculus. I have a quite simple scene with a Canvas and a plane (floor). Thanks to the Interaction SDK, I can use my hands to interact with the canvas. That part is working fine.
    But now, I would like to be able to point somewhere on the floor and get the position when I pinch my fingers.
    To do so, I put a Ray Interactable component and a Pointable Plane component on my floor. Right now, I can point the floor, I see the cursor moving on the floor as expected.
    My question is : How can I get in script the position on the floor of the cursor when I click (by pinching) ? Seems pretty simple but Oculus documentation does not help me.
    Thanks
     
  2. hyorange

    hyorange

    Joined:
    Feb 7, 2022
    Posts:
    4
    Answering my own question if someone ever needs it :
    • Add Ray Interactable and Pointable Plane to the plane
      • Ray Interactable : Pointable Element : leave empty. Collider : drop the plane collider component. Surface : drop the Pointable Plane component. Now you should be able to see your cursor on the plane with your hands. If you see it above your plane, scale down your plane on Y axis.
    • Now to get the cursor position, you can take it from the RayInteractor. In my case, I took it from HandRayInteractor: upload_2022-6-8_11-29-16.png
      • Link this to your script with
        public RayInteractor rayInteractor;
      • Now you can get the cursor position on your plane with
        Vector3 cursorPosition = rayInteractor.CollisionInfo.Value.Point;
     
  3. paulmac

    paulmac

    Joined:
    Feb 17, 2011
    Posts:
    10
    ray interactable, thanks thats what I was looking for