Returns the difference between two angles.


angle_difference(ang1, ang2)

Argument Description
ang1 The first angle to use.
ang2 The second angle to use.

Returns: Real


This function will return the smallest angle difference between two angles as a value between -180 and 180 degrees (where a positive angle is anti-clockwise and a negative angle clockwise).


var pd = point_direction(x, y, mouse_x, mouse_y);
var dd = angle_difference(image_angle, pd);
image_angle -= min(abs(dd), 10) * sign(dd);

The above code will get the angle of direction from the instance to the mouse cursor, then get the difference between that angle and the current image_angle, using this value to slowly rotate towards the mouse.

Back: Vector Functions
Next: point_direction
© Copyright YoYo Games Ltd. 2018 All Rights Reserved