Hey folks,
In my project I’m basically using the standard MouseOrbit.js script to rotate the camera around an object.
I’ve added additional functionality that allows me to rotate the camera around the z-axis which initially seemed to work fine, but after playing with it for a while I’ve found that the x and y rotation is off after I’ve rotated in the z.
So, if I rotate the camera 90 degrees in the z-axis, then drag the mouse along the x-axis, I seem to be rotating the camera in the y-axis instead of the x-axis.
Does that description make any sense? Basically, these rotation is calculated like so:
x += Input.GetAxis(“Mouse X”) * xSpeed * 0.02;
y -= Input.GetAxis(“Mouse Y”) * ySpeed * 0.02;
var rotation = Quaternion.Euler(y, x, myZ);
transform.rotation = rotation;
Somehow I need to change how I calculate the x and y rotation when myZ is changed (i.e. when I rotate 90 degrees it looks like I’ll want the axes flopped).
I’m having some difficulty with the math involved, so I figured I’d check to see if anyone had run across this problem before.
Thanks,
Jared