Skip to content

point_direction

drewmccluskey edited this page Jan 23, 2019 · 3 revisions

point_direction

returns directional degree based upon either two vector points or sets of X-Y input points.

Syntax:

point_direction(p1, p2) //Vector
point_direction(x1, y1, x2, y2) //X-Y

Vector

Argument Description
Vector2 p1 First position
Vector2 p2 Second position

X-Y

Argument Description
double x1 First x position
double y1 First y position
double x2 Second x position
double y2 Second y position

Returns: double

Description:

This function will return the directional degree angle projected from the first point to the second point coordinates. It is useful for programming AI as well as targeting objectives.

Vector Example:

var direction = point_direction(Position, new Vector2(100,200));

Above code will set an objects direction to whatever angle it's current position is relative to the position [100,200] by vector positions.

X-Y Example 2:

var direction = point_direction(x,y,100,200);

Above code will set an objects direction to whatever angle its current x and y position is relative to the position [100,200] by pixel positions.

Back to Shapes

Clone this wiki locally