I am seeking a way to achieve vertical movement using three.js's pointerlockcontrols
. Specifically, I desire the movement to be similar to three.js's flycontrols
, where the vertical direction of movement is proportional to the direction the user is looking (e.g., moving northeast results in simultaneous movement in the Y and Z axes).
My attempt so far has been:
if(keys[38] || keys[87]){
Controls.moveForward(playerSpeed);
Camera.position.y += Math.cos(Camera.rotation.y) * playerSpeed;
}
However, this code did not provide the desired behavior, as looking straight down would move the player forward significantly. I am puzzled by this issue and am seeking advice from anyone who has successfully tackled this problem before.