I’m working on an XR game that’s playable without a controller. As part of it, I need to calculate a ray from the center of the headset for firing a projectile. Is there any way of doing this?
I haven’t actually tested it, but I think the code would work.
// enable xr
let xr = await BABYLON.WebXRExperienceHelper.CreateAsync(scene);
// on input
let ray = xr.camera.getForwardRay()
let { origin, direction } = ray
// do something
3 Likes