Quaternion.RotateTowards to rotate beyond 360?

Hi,

This will probably sound noobish :slight_smile: But why Quaternion.RotateTowards won’t rotate beyond 360 degrees? Actually, even if I make the target 320 degrees, it will not rotate to 320 degrees but will go in the opposite direction to rotate to -40 degrees.

I understand what’s happening but I’m curious if this is an issue with quaternion rotations in general or with RotateTowards?

function Update () {
	
	var rotation : Quaternion;
	
	rotation.eulerAngles = Vector3(0, 320, 0);
	
	transform.rotation = Quaternion.RotateTowards(transform.rotation, rotation, 20*Time.deltaTime);

}

The only realistic way to do this would be to check if the rotational angle has reached 359 degrees. You need to understand that there is between -180 and 180. Therefore to make it go around 5 times you have two options.

  1. Use the animator and animate it going round 5 times.

    var speed = 10;

    function Update
    {

    if (transform.rotate.y => 90)
    {
     transform.Rotate(Vector3.up * Time.deltaTime * speed);
    }
    
    // do whatever when the planes move and repeat the above. 
    

Hope this helps.Code above is untested.