Forward/Backward strafing with Universal/Free Camera


This seems to be something that would have been answered already, however I cannot find it at all.

When using Universal camera, Keyboard and Gamepad controls do not strafe forward or back when pointing straight up or down when gravity and collisions are enabled (see playground). When holding up you try to fly ‘upwards’ but gravity pulls you down, and when pointing down, you collide with the floor.

Is there an easy way to implement up and down key (including gamepad) functionality to work analogously as left and right keys?

I am guessing in this case you do not want to enable gravity at all ?

Originally gravity was enabled so the free camera didn’t go to the sky when pointing upwards, but ever since then I added a couple of gimmicks that rely on gravity, so would rather not disable it.

The thing I want is if you look down (or up), to move at the same speed forward as you would if you moved sideways (same way as in CS:GO). Currently forward moves you to where the camera is pointing, which in a way makes sense, but not what I want to have happen. I guess I would need to somehow ignore the Pitch (and Roll, but it’s not applicable here) component.

Maybe @RaananW would have an idea ?

Just to add, Minecraft Classic has managed to pull this camera trick off, but after trying to understand their minified app.js source code, I couldn’t figure out how they managed to get it to work.