VR raycast from controller directly on an entity that has mesh collider

I am working on a project where I need to raycast from Oculus Go controllers to select an entity and highlight it using outline shaders. Outline works perfectly using mouse and touch, but cannot get it to work with VR, because getting the controller position and casting a ray forward from it does not seem to work. I did search for some references and the example provided by PlayCanvas. All these example uses the Bounding Box or Bounding Sphere to get the entities. Is there any way to get it working with Mesh Colliders!?

Should work with a physics raycast. It could worth checking the direction of the ray that you make is going in the direction that you think it is?

I am using physics raycast to do that, but how to set the from and to coordinates for the ray in VR. Can you please give me some details on the code!?

This is a cleaned up version of the project I am working on. Can you please go through the code!?


Link: https://playcanvas.com/editor/project/622669

The issue is that you are doing the raycast from the camera using the mouse position.

What you should be doing is a raycast from the two hand controllers in world space.

If you make the start position of the ray the world position of the controller entity and the end position to be 3 units along the forward direction of the controller entity, that should work.

Hmm…I am a bit new to PlayCanvas…can you please provide me with a piece of code on how to do that!?

If possible can you link me with an example project?..so that I can get a better understanding.
Also to note that, I am working in Oculus Go, I hope that does not matter.