Unhappy with my previous results I am now using the MouseOrbit script from the wiki.
Unfortunately my environment differs a bit from the assumptions in the script, in that the view is always from the top (e.g. Z = -50) on the X/Y grid (RTS style). The script assumes that one is operating in an environment where one is looking towards Z.
I don’t know why but for the love of Christ I cannot adapt the script to work in my alternate space… it doesn’t seem to be as simple to just change the axes - the rotations are all screwed up… any ideas?
Here the script:
x += Input.GetAxis("Mouse X") * 10f * distance * 0.02f;
y -= Input.GetAxis("Mouse Y") * 10f * 0.02f;
y = ClampAngle(y, yMinLimit, yMaxLimit);
Quaternion rotation = Quaternion.Euler(y, x, 0);
distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel") * 5, distanceMin, distanceMax);
Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
Vector3 position = rotation * negDistance + target.transform.position;
transform.rotation = rotation;
transform.position = position;