Hi,
I use the following snippet to smoothly turn entities:
Code:
var ship_rotateSpeed = 6;

function game_SmoothRotateToPos(&_pos)
{
	var target_vec[3];
	var angle[3];
	
	vec_set(target_vec,_pos);
	
	vec_diff(target_vec, target_vec, my.x);
	vec_to_angle(angle, target_vec);
	
	while(abs(my.pan-angle.pan) > ship_rotateSpeed)
	{
		if(ang(angle.pan - my.pan) < 0)
		{
   		my.pan -= clamp(abs(ang(angle.pan - my.pan)),0,ship_rotateSpeed) * time_step;
		} 
		else 
		{
	   	my.pan += clamp(abs(ang(angle.pan - my.pan)),0,ship_rotateSpeed) * time_step;
		}
		
		wait(1);
	}
	my.pan = angle.pan;
}


Now this works fine if the start pan of the entity is equal to zero.
However if the start pan is 180, it rotates but does not finish the rotation.
Instead it stops shortly before finishing it and never exists that while loop.

Anyone know why this happens?

Thanks in advance for any hints.