Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

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

pixelcasepixelcase Posts: 12
NerveGear
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.

Best Answer

Answers

  • shawnfromportlandshawnfromportland Posts: 3
    NerveGear
    @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
  • pixelcasepixelcase Posts: 12
    NerveGear
    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.
  • JacksonGordonJacksonGordon Posts: 138
    Art3mis
    edited February 20
    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/

  • pixelcasepixelcase Posts: 12
    NerveGear
    I'm still looking for a solution for this unfortunately, the above radio toggle selection did not work
  • radicalappdevradicalappdev Posts: 11
    NerveGear
    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.

  • pixelcasepixelcase Posts: 12
    NerveGear
    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?
  • radicalappdevradicalappdev Posts: 11
    NerveGear
    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.

  • pixelcasepixelcase Posts: 12
    NerveGear
    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?
  • MPeters-xwMPeters-xw Posts: 6
    NerveGear
    I'm trying to get Easy-Controler Selection to work, but I don't see the OVRPointerVisualizer script in the Integrations package.
  • pixelcasepixelcase Posts: 12
    NerveGear
    OVRPointerVisualiser is basically deprecated at this point, though it did provide me with a good laser pointer when I used it initially. Now, the latest Oculus Utilities has a different way to generate a laser pointer.

    In the end, I deleted all of my oculus stuff in my project and reinstalled it via the Asset Store, and then followed mfmf's advice above to check the usage in the DebugUI scenes, and basically copied that integration over to my scenes. 
Sign In or Register to comment.