# Legacy GMPause path

#### Sk8dududu

##### Member
So I have a bunch of paths that have anywhere from 4-10 points each. The object following the path needs to pause for about 1 second each time it reaches a new point in the path. Then continue onto the next point.
Not sure how to go about checking if the path is different.

#### Catastrophe

##### Member
I'm not a path expert, but if you need a working solution it'd be something like this:

Create:
mypath = stuff
curPoint = 1;
nextPointX = path_get_point_x(mypath,1)
nextPointY = path_get_point_y(mypath,1)

step:

if (point_distance(x,y,nextPointX,nextPointY) <= speed) {
x = nextPointX
y = nextPointY
// we're at the next point
< do your pausing stuff >
curPoint++
nextPointX = path_get_point_x(mypath,curPoint)
nextPointY = path_get_point_y(mypath,curPoint)
}

Last edited:
• Sk8dududu

#### Sk8dududu

##### Member
I'm not a path expert, but if you need a working solution it'd be something like this:

Create:
mypath = stuff
curPoint = 1;
nextPointX = path_get_point_x(mypath,1)
nextPointY = path_get_point_y(mypath,1)

step:

if (point_distance(x,y,nextPointX,nextPointY) <= speed) {
x = nextPointX
y = nextPointY
// we're at the next point
< do your pausing stuff >
curPoint++
nextPointX = path_get_point_x(mypath,curPoint)
nextPointY = path_get_point_y(mypath,curPoint)
}
This seems to work perfectly for the first point. The objects starts the path, pauses at the first point in the path where i have an alarm set to increase path speed again.
But every point after that it just fly's right past.

##### Member
This seems to work perfectly for the first point. The objects starts the path, pauses at the first point in the path where i have an alarm set to increase path speed again.
But every point after that it just fly's right past.
Can you post your implementation? Seems like the nextPointX & nextPointY aren't updating.

#### Sk8dududu

##### Member
Can you post your implementation? Seems like the nextPointX & nextPointY aren't updating.
All i did was pathspeed = 0 and alarm_set(1,30) where it stops in the step event.
And then in the alarm i set pathspeed = 5.

##### Member
Its hard to debug without seeing your actual code and the conditions to execute those statements, I'd recommend you use the debugger or show_debug_message() to log the values of the points and see where the issue pops up.

• Sk8dududu

#### Catastrophe

##### Member
It would make sense if there was an issue here:

curPoint++
nextPointX = path_get_point_x(mypath,curPoint)
nextPointY = path_get_point_y(mypath,curPoint)

If you forgot any of these lines or had a typo in them this won't work

But yeah, debugging yourself or pasting your alarm code would help. The important parts are the values of curPoint, nextPointX and nextPointY

Alternatively, "speed" might be incorrect in the if statement, I think it should be path_speed, or possible something involving path_speed. I would try:

if (point_distance(x,y,nextPointX,nextPointY) <= path_speed) {

and just as a sanity check

if (point_distance(x,y,nextPointX,nextPointY) <= (path_speed + 5)) {

Last edited:
• Sk8dududu