Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Hyorange's avatar
Hyorange
Explorer
3 years ago
Solved

Interaction SDK : Get click world position ?

Hello.
I'm trying to use the Interaction SDK. 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 can 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 the documentation does not help me.
Thanks

  • 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: 
      • 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 Replies

  • 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: 
      • 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;​

      

     

    • sludgybeast's avatar
      sludgybeast
      Honored Guest

      Thanks for helping with this! Able to get the interactor after hovering objects.

      How are you able to create custom event functions for those interactions ie hover, pinch, etc.