Skip to content

angle_difference

drewmccluskey edited this page Jan 23, 2019 · 4 revisions

angle_difference

returns the difference between two angles within -180 and 180 return values.

Syntax:

angle_difference(double src, double dest)

Vector

Argument Description
double src Current angle
double dest Desired angle

Returns: double

Description:

This function will return the difference between two input angles within -180 and 180. It is used to gather information to know which direction to rotate in the quickest way to get to a specific direction.

Example:

var driftAngle = angle_difference(direction, image_angle);
direction -= min(abs(image_angle), 15) * sign(driftAngle);

Above code will rotate an object's image angle towards its nearest current direction by an incremental method.

Back to Vectors

Clone this wiki locally