Skip to main content
New Participant
June 7, 2022
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

HyorangeAnswer
New Participant
June 8, 2022

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

HyorangeAuthorAnswer
New Participant
June 8, 2022

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

  

 

SirLuicelot
Participant
January 25, 2023

Thank you so much for telling the solution you found