This script will rotate an object when you move your finger on a touch screen device. All works fine, but how can I limit the angles to a minimum and maximum like the mouse look script does?
Any help would be greatly appreciated.
#pragma strict
private var rotate : float;
private var horozontalSpeed : float = 2.0;
private var verticalSpeed : float = 2.0;
var minimum : float;
var maximum : float;
function Update()
{
if (Input.touchCount == 1)
{
var touch : Touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved)
{
rotate = horozontalSpeed * touch.deltaPosition.x ;
transform.Rotate( 0, 0, -rotate, Space.World );
rotate = Mathf.Clamp (rotate, minimum, maximum);
}
}
}