# Is it possible to calculate the ray from the center of an XR headset

**URL:** <https://forum.babylonjs.com/t/is-it-possible-to-calculate-the-ray-from-the-center-of-an-xr-headset/43574>\
**Category:** Questions\
**Tags:** webxr, xr, ray, headset\
**Created:** [August 25, 2023, 4:05pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-calculate-the-ray-from-the-center-of-an-xr-headset/43574 "2023-08-25T16:05:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Symbitic](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/symbitic/32/3083_2.png) [@Symbitic](https://forum.babylonjs.com/u/Symbitic)\
**Post date:** [August 25, 2023, 4:05pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-calculate-the-ray-from-the-center-of-an-xr-headset/43574/1 "2023-08-25T16:05:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![qq2315137135](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/qq2315137135/32/32219_2.png) [@qq2315137135](https://forum.babylonjs.com/u/qq2315137135)\
**Post date:** [August 25, 2023, 5:01pm UTC](https://forum.babylonjs.com/t/is-it-possible-to-calculate-the-ray-from-the-center-of-an-xr-headset/43574/2 "2023-08-25T17:01:37Z")

</div>

I haven’t actually tested it, but I think the code would work.

```javascript
    // enable xr
    let xr = await BABYLON.WebXRExperienceHelper.CreateAsync(scene);

    // on input
    let ray = xr.camera.getForwardRay()
    let { origin, direction } = ray
    // do something

```
