Move flyCam while ignoring it's pitch

Hi all,

I was wondering if there is a way of moving the default flyCam’s position while ignoring it’s rotation (in particular, pitch). I drew a picture to help me explain: (I hope that displays correctly)

When I use the the W key to move the camera forward, it follows the red line into the scene. I want it to follow the blue line over the scene, but still move in the direction the camera is facing. I hope that’s clear enough for you guys to help.

you have to project the red line onto the blue. Normally done with dot products, but (assuming you are using the standard flycam) in this case you can just zero out the y component of the direction vector, normalize it, then use that instead.

Thanks for your reply. So… cam.getLocation(), cam.setLocation()? I remember looking through the javadocs for methods that would help but didn’t get very far. Can you elaborate just a little for a newb?

Look at and modify what it does when pressing W.

It will be something like:

The chain of commands is not valid (separate it out into multiple statements), but cba to write it all neat from my phone

That worked perfectly! Apparently, that chain of commands is perfectly valid, with an extra ) on the end :smiley: thank you very much.

1 Like

ah fair enough, I wasn’t expecting setY() to return a vector3f, so thought it would fail there. Glad it worked