Free Camera

Hi, I’m trying to create a free camera to travel around the map, like RTS games. More precisely like the World in Conflict camera. WASD to move on XY, scroll wheel for Z, and middle mouse button for rotating around (like a head, on camera pivot).

I can get the camera moving with WASD and turn around with the mouse, but it turns as soon as I click play, not only when RMB is pressed.

And another problem I don’t know how to resolve is the movement vector is always the same, not depending on where you look. If you look to the right from the original position, W still send you straight, not to the right (where you are looking).
So the vector should depend on the camera angle. How do I program that?

I hope I explained myself enought, any help is welcome, on already made things or tips to make it.

Simple trig should help you out immensely here.

I didn’t something similar for a work project, and the easiest thing to do is to grab a cross product with a vector local to the camera.

So, if you wanted to move forward, to get the forward vector, assuming the camera is at an angle, you’d have to do Vector3.Cross(Vector3.up, camera.transform.right) for forward/back and camera.transform.right for left/right, just using the negative to go the opposite way.

Also meant to mention that this should work with any rotation along Vector3.up and camera.transform.right, because the vector going to the camera’s right will always be correct, and Vector3.up will always be the up vector you need for the cross product.

I managed to get it done. I used vector3 like you said. Thx. Then I just limited the height equaling Y at the same value all the time. Changing based on mouse wheel