Three.js smooth camera
kwe (57)

I don't know how to make it so the transition from changing position more smooth, Any tips or help will be appreciated.

Ignore my horrible formatting and code lmao.

WASD and Q,E to move.

You are viewing a single comment. View All
Coder100 (18922)

there's a lot of things you can do.

First, use this code instead:

let keys = {};

document.addEventListener("keydown", e => {
  keys[e.which] = true;

document.addEventListener("keyup", e => {
  keys[e.which] = false;

then, on your animate scene, you add the arrow key movement, like this:

function animate() {
  if (keys[87]) {
  if (keys[83]) {
  if (keys[65]) {
  if (keys[68]) {
  if (keys[69]) {
  if (keys[81]) {

never ever use else if for movement, it prevents the player from strafing and pressing two keys at once!

kwe (57)

@Coder100 thank you so much! I cant explain how much time you saved me!