Forum Discussion
Hyorange
3 years agoExplorer
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;- Add Ray Interactable and Pointable Plane to the plane
3 Replies
- HyorangeExplorer
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;- SirLuicelotExplorer
Thank you so much for telling the solution you found
- sludgybeastHonored 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.
- Add Ray Interactable and Pointable Plane to the plane
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago