- Home /
Question by
Erwin-Broekhuis · Jan 02, 2017 at 08:25 AM ·
camera-movementinput.getaxis
Orthographic camera movement
I'm working on a simple camera dragging script. I've tried several scripts from examples I found on the web, but they don't work on my orthographic camera because they translate the Y axis, which I do not want to change. So I came up with the idea of translating x and y axis of the mouse and use it to manipulate the x and z position of the camera transform. I works if I use this principle on my keyboard (i.e. Input.GetAxis("Horizontal")), but not with the mouse.
Can anyone help? What am I missing here?
void MousePan()
{
//Mouse button pressed?
if (!Input.GetButtonDown("Fire1"))
{
return;
}
float translationY = Input.GetAxis("Mouse Y") * speed;
float translationX = Input.GetAxis("Mouse X") * speed;
transform.Translate(translationX + translationY, 0, translationY - translationX);
}
Comment