cancel
Showing results for 
Search instead for 
Did you mean: 

Interaction SDK : Get click world position ?

Hyorange
Level 3

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

1 ACCEPTED SOLUTION

Accepted Solutions

Hyorange
Level 3

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

  

 

View solution in original post

1 REPLY 1

Hyorange
Level 3

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