Back and Forth Movement


I was playing with this sample:

I transferred it to my project in a similar way. If you put the camera right on the ground and try to move, you will also see that it doesn’t go back and forth. However, where the camera is looking should not be very important, if it wants to go forward, looking at the ground should not reduce its speed, etc.

Does anybody have any idea how I can do it?

This is by default with this code. We are reversing from camera view matrix into world. Hence the direction of where the camera look matters.

Here is a quick fix:

                    camera._transformedDirection.y = 0;
                    camera._transformedDirection.x *= speed;
                    camera._transformedDirection.z *= speed;

For line #207: Walk Around and Look Around Camera for BJS V4.2+ | Babylon.js Playground (

I cancelling the vertical component and rebuilding the direction to only be on the XZ plane

1 Like

Cool, thanks.