Hi folks,
I’m making an object the camera is attached to rotate on the X axis when the mouse moves to the top 5 or bottom 5 pixels on the screen. Standard rts kinda navigation.
It’s working fine, but I’m running into a problem with limiting the rotation. Because the X rotation of the object is set to 0 initially, if I rotate down then it flips to a rotation of 359 degrees, rather than -1.
If I set the initial rotation to, say 90, it pooches other scripts ![]()
Any ideas on a workaround for this, you clever folks, you?
var camyoffset : int = 5;
var camrot : float = 5;
function Update () {
if(Input.mousePosition.y < camyoffset transform.localEulerAngles.x > -20) {
transform.Rotate((camrot * -1 * Time.deltaTime), 0, 0);
}
if(Input.mousePosition.y > Screen.height-camyoffset transform.localEulerAngles.x < 20) {
transform.Rotate((camrot * Time.deltaTime), 0, 0);
}
}
Cheers,
- Jon