# Oculus controller joystick - camera fly

**URL:** <https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979>\
**Category:** Questions\
**Tags:** camera\
**Created:** [July 7, 2022, 9:12am UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979 "2022-07-07T09:12:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cosmos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cosmos/32/25418_2.png) [@cosmos](https://forum.babylonjs.com/u/cosmos)\
**Post date:** [July 7, 2022, 9:12am UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/1 "2022-07-07T09:12:17Z")

</div>

How to fly the camera with oculus controller joystick in the direction the controller is facing

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [July 7, 2022, 1:33pm UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/2 "2022-07-07T13:33:15Z")

</div>

ping @RaananW

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 7, 2022, 11:44pm UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/3 "2022-07-07T23:44:42Z")

</div>

@cosmos If you can provide a playground with what you have so far that would be helpful. Did you try to get the transform of the controller?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [July 11, 2022, 12:02pm UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/4 "2022-07-11T12:02:10Z")

</div>

Wanted to add on top of that - I am not sure what “fly the camera” means. We have teleportation, this technically allows you to “fly” to a different location, based on the controller direction. We also have movement module(s) that allow you to walk in a specific direction. I assume one of those can help you?

---

<div class="post-metadata">

**Author:** ![cosmos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cosmos/32/25418_2.png) [@cosmos](https://forum.babylonjs.com/u/cosmos)\
**Post date:** [July 18, 2022, 7:21am UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/5 "2022-07-18T07:21:12Z")

</div>

from fly camera i meant a free camera movement we have with keyboard. I do not want to teleport want a smooth movement.  
can u please link example of the movement modules you have mentioned.

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [July 18, 2022, 10:55am UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/6 "2022-07-18T10:55:20Z")

</div>

> **[WebXR Selected Features | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/webXR/WebXRSelectedFeatures#movement-module)**
>
> Learn about key WebXR features in Babylon.js.

---

<div class="post-metadata">

**Author:** ![cosmos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cosmos/32/25418_2.png) [@cosmos](https://forum.babylonjs.com/u/cosmos)\
**Post date:** [July 18, 2022, 1:35pm UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/7 "2022-07-18T13:35:05Z")

</div>

```auto
const attachControllers = (xrHelper: WebXRExperienceHelper) => {
    const controllers = new WebXRInput(
      xrHelper.sessionManager,
      xrHelper.camera
    );
    const xrayPointer = new WebXRControllerPointerSelection(
      xrHelper.sessionManager,
      {
        disablePointerUpOnTouchOut: false,
        disableScenePointerVectorUpdate: false,
        forceGazeMode: false,
        xrInput: controllers,
      }
    );
    xrayPointer.displayLaserPointer = true;
    xrayPointer.attach();
    return controllers;
  };

  useEffect(() => {
    const enableXR = async () => {
      if (isVREnabled && scene != null) {
        const xrHelper = await WebXRExperienceHelper.CreateAsync(scene);
        const xr = attachControllers(xrHelper);
        await xrHelper.enterXRAsync(
          'immersive-vr',
          'local-floor',
          undefined,
          {}
        );
        const featureManager = xrHelper.featuresManager
        featureManager.disableFeature(BABYLON.WebXRFeatureName.TELEPORTATION);
        featureManager.enableFeature(BABYLON.WebXRFeatureName.MOVEMENT, "latest", {

          xrInput: xr,
          
          });
      }
    };
    enableXR();
  }, [isVREnabled]);

```

I m using the above code to enable webvr, controllers and movement.  
but doesn’t seem to move can u help with what m i doing wrong

---

<div class="post-metadata">

**Author:** ![cosmos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cosmos/32/25418_2.png) [@cosmos](https://forum.babylonjs.com/u/cosmos)\
**Post date:** [July 21, 2022, 9:52am UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/8 "2022-07-21T09:52:17Z")

</div>

```auto
return (
    <>
      <universalCamera
        name="universal"
        target={new Vector3(0, 0, 0)}
        position={new Vector3(0, 0, 0)}
        rotation={new Vector3(0, 0, 0)}
        speed={1}
        angularSensibility={1800}
        fov={1}
        touchAngularSensibility={1000}
        touchMoveSensibility={0}
        ref={cameraRef}
      />
      <hemisphericLight name="light1" intensity={10} direction={Vector3.Up()} />
      <box
      name='box 1'
      size={2}
      position={new Vector3(0, 0, -999999)}
    >
      <standardMaterial
        name='box mat'
        diffuseColor={Color3.Red()}
        specularColor={Color3.Black()}
      />
    </box>
      { <Suspense
        fallback={
          <box
            name="left"
            height={0}
            width={0}
            position={new Vector3(0, 0, 0)}
          ></box>
        }
      >
        {sceneURL !== '' && sceneName !== '' ? (
          <Model
            name={sceneName.split('.')[0]}
            reportProgress
            position={new Vector3(0, 0, 0)}
            rootUrl='models/'
            sceneFilename='venue16x9_Screen_V1.glb'
            scaleToDimension={400.0}
            onModelLoaded={(model) => onLoaded(model)}
          />
        ) : (
          <box
            name="left"
            height={0}
            width={0}
            position={new Vector3(0, 0, 0)}
          ></box>
        )}
      </Suspense> }
    </>
  );

```

I added a dummy box in the scene and the movement seems to work now, remove that box and the movement doesn’t work, any idea why this might be happening @RaananW

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [July 21, 2022, 10:48am UTC](https://forum.babylonjs.com/t/oculus-controller-joystick-camera-fly/31979/9 "2022-07-21T10:48:24Z")

</div>

Feels very odd, but I won’t be able to test that without a working reproduction. This code seems to be a react code with no context or project setup, so it is very hard for me to understand the code. A playground would be great.
