Hmm that doesn’t do the trick. Maybe I explained myself wrong since it’s very hard to explain non-visually I uploaded a video.
http://www.screencast.com/t/ODBmMWIyNDc
As you can see, I click the mouse in the center of the screen and the camera shouldn’t orbit unless I drag the mouse. It works fine at the beginning. Now, wait in the video until I take off, you’ll see I click the center and the camera orbits… I have no idea why. It seems to orbit randomly, when I continue turning it will rotate less or more.
I use the same script than on the wiki. I tried to set
xDeg = Vector3.Angle(Vector3.right, transform.right );
yDeg = Vector3.Angle(Vector3.up, transform.up );
On mouse click down, just to restart the posititioning and see if that helped, but same issue.
This is my code on LateUpdate:
[quote]
if (Input.GetMouseButton(0)) {
if (rotating) {
xDeg -= Input.GetAxis("Mouse X") * xSpeed * 0.02f;
yDeg += Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
////////OrbitAngle
//Clamp the vertical axis for the orbit
yDeg = ClampAngle(yDeg, yMinLimit, yMaxLimit);
// set camera rotation
camTr.rotation = Quaternion.Lerp(camTr.rotation, Quaternion.Euler(yDeg, xDeg, 0), Time.deltaTime * zoomDampening);
// calculate position based on the new currentDistance
camTr.position= target.position - (camTr.rotation * Vector3.forward * distance);
}
}
if (!rotating Input.GetMouseButtonDown(0)) {
// only activate camera rotation if clicked in the main screen area
if (Input.mousePosition.y>CalcHeight(90) Input.mousePosition.y < CalcHeight(270) Input.mousePosition.x > CalcWidth(70)) {
rotating=true;
// restart angles, we are going to begin orbiting
xDeg = Vector3.Angle(Vector3.right, transform.right );
yDeg = Vector3.Angle(Vector3.up, transform.up );
} else if (Input.GetMouseButtonUp(0)) {
// no more orbiting
if (rotating) {
rotating=false;
}
}
[/quote]
(jezz how do I paste code in here now?)