I’m using the c# MouseOrbitImproved script. I’ve actually got this to work by just commenting out the raycaster bit.
void LateUpdate () {
if (target) {
x += Input.GetAxis("Mouse X") * xSpeed * distance * 0.02f;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
y = ClampAngle(y, yMinLimit, yMaxLimit);
Debug.Log (y);
Quaternion rotation = Quaternion.Euler(y, x, 0);
distance -= Input.GetAxis("Mouse ScrollWheel")*1.5f;
Debug.Log ("distance = " + distance);
distance = Mathf.Clamp(distance, distanceMin, distanceMax);
// distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel")*1.5f, distanceMin, distanceMax);
RaycastHit hit;
if (Physics.Linecast (target.position, transform.position, out hit)) {
distance -= hit.distance;
}
Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
Vector3 position = rotation * negDistance + target.position;
transform.rotation = rotation;
transform.position = position;
RaycastHit hit;
if (Physics.Linecast (target.position, transform.position, out hit)) {
distance -= hit.distance;
}
Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
Vector3 position = rotation * negDistance + target.position;
transform.rotation = rotation;
transform.position = position;
}