# Three.js First Person Camera Movement Issue

**URL:** <https://discourse.threejs.org/t/three-js-first-person-camera-movement-issue/18670>\
**Category:** Questions\
**Tags:** firstperson-controls, camera-controls, camera\
**Created:** [September 13, 2020, 6:10pm UTC](https://discourse.threejs.org/t/three-js-first-person-camera-movement-issue/18670 "2020-09-13T18:10:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous\_Reviewer](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/anonymous_reviewer/32/13287_2.png) [@Anonymous\_Reviewer](https://discourse.threejs.org/u/Anonymous_Reviewer)\
**Post date:** [September 13, 2020, 6:10pm UTC](https://discourse.threejs.org/t/three-js-first-person-camera-movement-issue/18670/1 "2020-09-13T18:10:25Z")

</div>

I am having more problems with my threejs code. I have got the camera working properly as an FPS camera, but the WASD movement is having some problems. I am using the camera.getWorldDirection to change the movement direction whilst the player is still trying to move.

```javascript
    var direction = new THREE.Vector3();
    var direction = camera.getWorldDirection(direction);

    if(evt.keyCode == 87){ // W key
        camera.position.add(direction.multiplyScalar(distance));
    } 

```

However, I do not want the players Z axis to be changed during this. Currently it is like a freecam mode, and is very jerky. I want to smooth this and not effect the z axis. The player cannot be able to fly!

Also, for the D key, how can i reverse this? If anyone has a better way of doing this pls let me know.

> <https://stackoverflow.com/questions/63863887/three-js-camera-movement-issue>

No one has answered in a day so I would appreciate if someone could help me out 😃

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [September 14, 2020, 2:33am UTC](https://discourse.threejs.org/t/three-js-first-person-camera-movement-issue/18670/2 "2020-09-14T02:33:44Z")

</div>

There are a couple of first person camera control plugins available, adapting one of them might be easier than creating your own from scratch.

> [@Third-Person Camera](https://discourse.threejs.org/t/third-person-camera/18624):
>
> Here are some basic examples i made for implementing a third-person camera. In order to avoid a stiff attachment to the player we can smoothly lerp the camera or camera rig to the goal to compensate quick motions. First the more ideal dolly concept which respects the dolly distance, moving the camera dolly behind the player again even when not moving. Dolly + goal (use keyboard ASDW) Fixed goal: [https://codepen.io/Fyrestar/pen/zYqjNOL](https://codepen.io/Fyrestar/pen/zYqjNOL) This is the first example i made longer ago. As you se…

> <https://github.com/mrdoob/three.js/blob/c95ea0b9babd195eaec9f93c6593d2eaa1a51a33/examples/jsm/controls/FirstPersonControls.js>

---

<div class="post-metadata">

**Author:** ![Anonymous\_Reviewer](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/anonymous_reviewer/32/13287_2.png) [@Anonymous\_Reviewer](https://discourse.threejs.org/u/Anonymous_Reviewer)\
**Post date:** [September 14, 2020, 5:40am UTC](https://discourse.threejs.org/t/three-js-first-person-camera-movement-issue/18670/3 "2020-09-14T05:40:27Z")

</div>

Thanks for your reply. The only problem is that it might be difficult for me to implement this into socketio as well. I was planning on making custom movement such as bhopping, slide hopping walljumping. I guess I’ll have to do more research.

The smooth lerp if helpful thanks
