angle_difference

Returns the difference between two angles.

Syntax:

GML Code Example

angle_difference(ang1, ang2)


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


Returns: Real


Description

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).


Example:

GML Code Example

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.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here