I’m trying to ‘simply’ rotate a camera in x degree steps on a function. I have managed to to this fine for a clockwise direction (with a hack when it gets to 360 degrees) but my anticlockwise direction is all screwed up. It strikes me that there must be a much easier way of doing this simple task? Anyone got any ideas? ie…is there any way I can have angle increment beyond 360 degrees perhaps?
Thanks
function rotateClockwiseToPosition(degrees : int )
{
var getInitialRotation : int;
getInitialRotation=myPivot.transform.eulerAngles.y;
while (myPivot.transform.eulerAngles.y<((getInitialRotation+degrees)))
{
//switch 360 to 0 if moving clcokwise
if(myPivot.transform.eulerAngles.y<50&getInitialRotation<360&getInitialRotation>200)
{
myPivot.transform.eulerAngles.y=0;
getInitialRotation=0;
break;
}
cameraAutoMoving=true;
myPivot.transform.Rotate(Vector3(0,1,0),cameraSpeed*Time.deltaTime);
yield;
}
}
function rotateAntiClockwiseToPosition(degrees : int )
{
var getInitialRotation : int;
getInitialRotation=myPivot.transform.eulerAngles.y;
if (getInitialRotation==0)
{
getInitialRotation=360;
myPivot.transform.eulerAngles.y=getInitialRotation;
}
while (myPivot.transform.eulerAngles.y>((getInitialRotation-degrees)))
{
//switch 360 to 0 if moving clcokwise
if(myPivot.transform.eulerAngles.y>3100&getInitialRotation>0&getInitialRotation<120)
{
myPivot.transform.eulerAngles.y=360;
getInitialRotation=360;
break;
}
cameraAutoMoving=true;
myPivot.transform.Rotate(Vector3(0,1,0),-cameraSpeed*Time.deltaTime);
yield;
}
}