-
-
Notifications
You must be signed in to change notification settings - Fork 18
point_direction
drewmccluskey edited this page Jan 23, 2019
·
3 revisions
returns directional degree based upon either two vector points or sets of X-Y input points.
point_direction(p1, p2) //Vector
point_direction(x1, y1, x2, y2) //X-Y
Argument | Description |
---|---|
Vector2 p1 |
First position |
Vector2 p2 |
Second position |
Argument | Description |
---|---|
double x1 |
First x position |
double y1 |
First y position |
double x2 |
Second x position |
double y2 |
Second y position |
Returns: double
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.
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.
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 Vectors