Player & camera movement

I have a small project where I am developing character movement. Currently, it works as follows: when the user presses one of the buttons (WASD), I rotate the character in the desired direction using the setEulerAngles function. Accordingly, the character always moves in one direction when the same button is pressed. I want the character to turn, for example, to the right and for the camera to rotate in the same direction (i.e., look at the back of the character) so that when the D key is pressed, the character moves to the right, when W is pressed, it moves straight, etc. I saw that project, but I don’t want the camera to rotate the character on each frame, only change the direction of movement of the corresponding keys. I don’t understand how to do this properly.

I know that cameras, like any other Entity, have the properties “forward” and “right”. But I’m not sure how to use them correctly.

https://playcanvas.com/editor/scene/1724182

Hi @teleportlab,

If I understand correctly, to do that you can use the camera forward/right vectors as your starting point. So basically replace this:

    var forward = this.player.forward;
    var right = this.player.right;

With this:

    var forward = this.camera.forward;
    var right = this.camera.right;

That way forward/side movement will be calculated based on the direction the camera is looking towards.