Moving in the direction the camera is looking, but projected onto a plane

Hi!

I’m using ChaseCamera. I want to move my character in the direction the camera is looking, but projected on the X-Z-plane, i.e. the ground plane. What is the best method to achieve this? To be clear: What I really want is the projected vector. The whole move thing is not important.

Also, say I found out how to get a vector out of the camera or chase camera, what do I do about the following problem? Say I get the camera to look straight down onto my character. Then the vector projected onto the ground plane would be (0, 0), but still the ChaseCamera has some idea of what “forward” is because if I move the mouse down, the camera will come back down the same way it went up.

Any ideas?

Vector3f myDirection3d = …
myDirection3d.y = 0;
myDirection3d.normalizeLocal();

If x and y are 0 then use the camera’s up vector.

1 Like

Although I can now see, reading my post again, why you might have thought that I had a problem with projecting the vector, what I was most interested in for the first part of my question was whence do I get the 3d vector? It seems getDirection and getUp together solve all problems, but as I didn’t know at first how to solve the second problem, I thought I’d ask the first part too, in case there was an even easier solution.

Anyway, thank you!