Hey, here is a new one for you!
I want a maximum and minimum angle and I came up with this
function Update () {
if (transform.eulerAngles.y > 10)
transform.eulerAngles.y = 10;
if (transform.eulerAngles.y < -10)
transform.eulerAngles.y = -10;
}
But for some reason it's making my object rotate but kinda stutterly. This object is being moved by mouse with this script:
static var autoRotate : boolean;
var rotateSpeed : float = 10;
var MousePos : float;
var XPos : float = 0;
function OnMouseDown () {
autoRotate = true;
}
function OnMouseUp () {
autoRotate = false;
}
function LateUpdate () {
MousePos = Input.GetAxis("Mouse X");
XPos = (-MousePos * rotateSpeed);
if (autoRotate)
transform.Rotate(Vector3.up * XPos);
}
Now I my question; where do I, or Unity, go wrong?