cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get the Laser Pointer from Easy Controller Selection guide to 'collide' with UI Canvas?

pixelcase
Honored Guest
I have followed the tutorial at https://developer.oculus.com/blog/easy-controller-selection/ and succesfully got a Laser Pointer to interact with world-space UI canvases, but the laser beam (from OVRPointerVisualiser) attached to my controllers goes through the canvas, despite working for interaction.

Is there a simple way to allow the laser pointer beam to 'collide' with the canvas to display a dot or ring moving along the canvas panel surface, instead of just travelling through the canvas? I know I can adjust the length of the laser beam but I have UI panels at different depths so need the laser beam to display a dot at different depths per each canvas.
1 ACCEPTED SOLUTION

Accepted Solutions

mfmf
Oculus Staff
Any of our sample scenes (in the SampleFramework folder) should do that, with the DebugUI. It updates the endpoint every frame so that the laser doesn't go through the canvas. Not saying you need to use the sample, but that the code itself to do that update is only a few lines.

View solution in original post

12 REPLIES 12

shawnfromportla
Explorer
@pixelcase
did you solve it? I have the exact same question. I got to where i have a laserpointer coming from the controller with a OVRPhysicsRaycaster and it can trigger Events, but I too am trying to make the laser "end" at the point where it collides with another collider. No luck yet after a full day on it. would prefer an "official" solution not a hacked together one

pixelcase
Honored Guest
Still no luck on my end.. spending my time on more important features. I've just reduced the length of the laser pointer (easily done via the inspector with this prefab).

But yeah, I would really appreciate an official solution instead of combining multiple plugins.

Anonymous
Not applicable
I've done a lot of work with the laser pointer recently.  For a canvas, there should be a radio toggle on the right side called "raycast target," make sure that is on (enabled).  That didn't always work for me, so as a last option (not ideal) you can add a box-collider to the canvas for it to interact with. 
Here is a much more detailed guide - https://developer.oculus.com/blog/easy-controller-selection/

pixelcase
Honored Guest
I'm still looking for a solution for this unfortunately, the above radio toggle selection did not work

radicalappdev
Protege
I was reading about this the other day. Oculus has an interesting idea
...either extending all the way to the UI or fading after a few inches

https://developer.oculus.com/design/latest/concepts/bp-userinput/

Once I read that I started noticing it everywhere. Instead of drawing the laser at a high distance, just draw a few inches to give the user the idea if using a laser pointer. Then use the raycast hit position to place a cursor on the UI. Oculus even does this with the menu screens on the Go and I never really noticed until I read about it.

pixelcase
Honored Guest
That sounds like a great idea actually. Do you know of any resources to raycast the hit position on canvas using OVRRaycaster (ray from the controller) rather than standard unity raycast tutorials?

radicalappdev
Protege
This is what I used. They provided some good examples of how to use the laser pointer for different things. You may need to make a new line renderer that to use in place of the one provided if you want to do the "short version" of the laser.

https://developer.oculus.com/blog/easy-controller-selection/

Keep in mind that the Raycast hit point and the line renderer are separate things. You are not actually Raycasting the line renderer. 
Use Raycast hit to get a transform in world space. 
Then use that transform to place a UI dot or indicator.

Basically, Raycasting is just a neat way of getting a transform in space that you can then use in code, setting the transform.position of another object.

pixelcase
Honored Guest
I've had issues with that blog post because the OVR Utilities and contained scripts keep changing. So I'm at the point where I just want to script the Raycast hit myself manually.

So, I've got my OVRPointerVisualiser and it's spitting out a laserbeam LineRenderer. I've got my canvases with OVRRaycaster scripts attached to them. The raycaster is obviously working because it's registering my 'clicks' when I pull the controller trigger on my buttons.

So, how do I script a Raycast hit to run on the Update function or similar so when I move laser onto the canvas (OnPointerEnter?) it is constantly sending the correct position to a laser dot sprite?