# Smooth camera rotation

**URL:** <https://forum.babylonjs.com/t/smooth-camera-rotation/31929>\
**Category:** Questions\
**Tags:** camera\
**Created:** [July 5, 2022, 10:48am UTC](https://forum.babylonjs.com/t/smooth-camera-rotation/31929 "2022-07-05T10:48:45Z")\
**Posts on this page:** 4\
**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 5, 2022, 10:48am UTC](https://forum.babylonjs.com/t/smooth-camera-rotation/31929/1 "2022-07-05T10:48:45Z")

</div>

my camera rotation is choppy, how can i make it smooth

```auto
const [rotationX, setRotationX] = useState(0);

  const [rotationY, setRotationY] = useState(0);

  const handleKeyDown = (event: KeyboardEvent) => {

    if (cameraRef !== null && cameraRef.current !== null) {
    
    console.log((cameraRef.current as UniversalCamera).rotation);
    
    }
    
    if (event.key == "d" || event.key == "D") {
    
    setRotationY((rotationY) => rotationY + 0.01);
    
    }
    
    if (event.key == "a" || event.key == "A") {
    
    setRotationY((rotationY) => rotationY - 0.01);
    
    }
    
    if (event.key == "w" || event.key == "W") {
    
      setRotationX((rotationX) => rotationX + 0.2);
    
    }
    
    if (event.key == "S" || event.key == "s") {
    
      setRotationX((rotationX) => rotationX - 0.2);
    
    }
    
    };

  useEffect(() => {

    window.addEventListener("keydown", handleKeyDown);
    
    return () => {
    
    window.removeEventListener("keydown", handleKeyDown);
    
    };
    
    }, []);

  return (
    <>
      <universalCamera
        name="universal"
        target={new Vector3(0, 0, 0)}
        position={new Vector3(0, 0, 0)}
        rotation={new Vector3(rotationX, rotationY, 0)}
        speed={1}
        angularSensibility={1800}
        fov={1}
        touchAngularSensibility={1000}
        touchMoveSensibility={0}
        ref={cameraRef}
      />

```

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [July 5, 2022, 11:01am UTC](https://forum.babylonjs.com/t/smooth-camera-rotation/31929/2 "2022-07-05T11:01:32Z")

</div>

Hi,  
You can ease the camera using the [easing function](https://doc.babylonjs.com/typedoc/classes/BABYLON.EasingFunction) and (although I never tried it) it looks like you can even use bezier curves.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [August 3, 2022, 12:08pm UTC](https://forum.babylonjs.com/t/smooth-camera-rotation/31929/3 "2022-08-03T12:08:35Z")

</div>

Hello @cosmos just checking in if you’d like any more help with this.

---

<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:** [August 4, 2022, 6:58am UTC](https://forum.babylonjs.com/t/smooth-camera-rotation/31929/4 "2022-08-04T06:58:40Z")

</div>

Used this

> [@Rotate Universal camera with WASD keys](https://forum.babylonjs.com/t/rotate-universal-camera-with-wasd-keys/31919):
>
> want to use WASD keys to rotate the universal camera in my scene. saw this example code: Trying to convert this example to typescript, totally unsuccessful, if anyone can help.
