This is a function that you can stick in a destination angle, the current angle, a speed cap, and a motion speed, and it will return the new angle.

Use -1 for no cap.

//rot_smooth(dest_angle,angle_value,speed,cap) var dest_angle, diff; dest_angle = argument0; angle_value = argument1; diff = dest_angle - angle_value; //This is where the action is! if (diff >= 180 && angle_value < 180) { angle_value += 360; } else if (diff <= -180) { angle_value -= 360; return angle_value; } //Check the cap if (argument3 == -1) { angle_value += diff / argument2; } else { if (diff / argument2 < argument3) { angle_value += diff / argument2; } else { angle_value += argument3*sign(diff); } } //Spit it out... return angle_value;;

Now, if you don't want it to have variable speed, and instead have it rotate at a constant speed until it hits the destination, then:

//rot_constant(dest_angle,angle_value,speed) var dest_angle, diff; dest_angle = argument0; angle_value = argument1; diff = dest_angle - angle_value; //This is where the action is! if (diff >= 180 && angle_value < 180) { angle_value += 360; } else if (diff <= -180) { angle_value -= 360; } else { if (angle_value != dest_angle) { var diff; diff = dest_angle - angle_value; if (abs(diff) < argument2) { angle_value += diff; } else { angle_value += argument2*sign(diff); } } } //Spit it out... return angle_value;

This will have one small hiccup, but it is hardly noticeable. Take these codes and paste them into a script, and to call them in an object, just use the instructions in the first line of each script.

BTW: When speed = 1, it moves instantly. When it is 100, it will move 1/100 of the distance every frame.

**You don't have to refrence me, but I sure wouldn't mind!**
**Edited by Anzkji, 02 March 2012 - 08:51 PM.**