Legacy GM Path end issues [SOLVED]

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
Code:
path = path_add();
STEP
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);
}
DRAW
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);
}
 

Alexx

Member
You can set whether the path is a closed loop or not:
Code:
path_set_closed(path,false);
There is an Event for path ended:
Add Event>>Other>>Path Ended

You can place your end of path reached code in the above event.
 
Last edited:

Simon Gust

Member
You can set whether the path is a closed loop or not:
Code:
path_set_closed(path,false);
The is an Event for path ended:
Add Event>>Other>>Path Ended

You can place your end of path reached code in the above event.
Aha, that's exactly what I needed. Thank you very much!

Should've read the manual a bit more.
 
Top