Simon Gust
Member
Hello,
I’ve recently started learning paths and pathfinding.
It works well and I undestand what the path functions and variables do.
The problem I have is that path_position is based on distance.
I wanted to end a path at the last point of the path but since paths always end at the start I can’t do that.
My question is: Is there a built-in variable, function or method to check if the last point has been reached?
I can’t check the coordinates as it would most likely cause infinite missing.
CREATE
STEP
DRAW
I’ve recently started learning paths and pathfinding.
It works well and I undestand what the path functions and variables do.
The problem I have is that path_position is based on distance.
I wanted to end a path at the last point of the path but since paths always end at the start I can’t do that.
My question is: Is there a built-in variable, function or method to check if the last point has been reached?
I can’t check the coordinates as it would most likely cause infinite missing.
CREATE
Code:
path = path_add();
Code:
if (path_get_number(path) >= 6)
{
if (path_position <= 0) {
path_start(path, 2, path_action_stop, true);
}
else
if (path_position >= 0.50) { // <= not suitable
path_end();
path_clear_points(path);
path_position = 0;
}
}
else
if (mouse_check_button_pressed(mb_left)) {
path_add_point(path, mouse_x, mouse_y, 100);
}
Code:
draw_circle(x, y, 5, 1);
for (var i = 0; i < path_get_number(path); i++)
{
var xx = path_get_point_x(path, i);
var yy = path_get_point_y(path, i);
draw_point(xx, yy);
}