Camera movement independent of rotation (219461)

Hi, I have a camera which moves left right up and down using mouse getAxis.

I get the the mouse axis values and add them to a variable called movementOffset. The camera moves fine when it has no rotation, but when i rotate it, the camera moves in weird directions rather than left right up and down. How can I translate the movementOffset in such a way that the camera always moves left right up and down no matter what the rotation is.

How I move:

movementOffset += new Vector3(Input.GetAxis("Mouse X"), 0, Input.GetAxis("Mouse Y"));
transform.position += movementOffset;

Have you tried setting a parent for you camera and moving that. And rotate the camera as a child?

@BruceKristelijn that doesn't works because I am changing the global position of the camera not local...

1 Answer

1

try (not tested) :

movementOffset = (Vector3.right* Input.GetAxis(“Mouse X”)) + ( Vector3.up* Input.GetAxis(“Mouse Y”));

doesn't works fine, the Y axis still has the issue....