- Home /
Move object on local axis instead of world axis after rotation
I currently have a camera that utilises a RotateAround function, with parameters of (1) a point defined by an object, (2) Vector3.up, and (3) a rotation speed float variable. The camera rotates upon pressing either the Q or E key.
I also have a 'move' function in Update, as follows:
void move()
{
Vector3 mov = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
float speed = 20.0F;
tf.position += mov * speed * Time.deltaTime;
}
When attempting to move the camera after pressing Q or E, it continues to move in World space instead of Local space (on the camera's local axis), meaning pressing W (forward) after rotating moves the camera to the left, right or backwards from my perspective, depending on the current rotation. I'd like to be able to move the camera according to its own current rotation: how would I go about this?
Thanks in advance for any help.
Comment