- Home /
how can i limit rotation on x and y
hi all , please how i can limit the rotation on x and y .. i,m still a biggener this is my code :
var h : float;
var v : float;
var horozontalSpeed : float = 2.0;
var verticalSpeed : float = 2.0;
if (touch.phase == TouchPhase.Moved){
h = horozontalSpeed * touch.deltaPosition.x ;
transform.Rotate( 0, h, 0);
v = verticalSpeed * touch.deltaPosition.y ;
transform.Rotate( v, 0, 0);
}
Comment
Answer by deprofundiis · Nov 04, 2014 at 11:21 AM
I think you are trying ask how to clamp values. Check this function from reference: http://docs.unity3d.com/ScriptReference/Mathf.Clamp.html
Here is how I do it in one of my controller scripts:
cursorX = Mathf.Clamp (cursorX, minimumX, maximumX);
cursorY = Mathf.Clamp (cursorY, minimumY, maximumY);
Hope it helps!
Your answer
