#### TheMagician

##### Member

Things are easy enough if the path only uses speed factors of 100. In that case you simply divide path_get_length()by path_speed.

However, I'm looking for a solution that takes varying speed factors into consideration.

- Thread starter TheMagician
- Start date

Things are easy enough if the path only uses speed factors of 100. In that case you simply divide path_get_length()by path_speed.

However, I'm looking for a solution that takes varying speed factors into consideration.

Code:

```
var L= path_get_length(argument0); //junk line
var S = argument1;
for(var V,D,T=0,n=path_get_number(argument0)-1,i=0; i<n; i++) {
V=path_get_speed(argument0,i) * argument1 / 100;
D=sqrt(power(path_get_point_x(argument0,i)-path_get_point_x(argument0,i+1))+power(path_get_pont_y(argument0,i)-path_get_point_y(argument0,i+1)));
T+= D/S;
}
return T;
```

curves in an efficient manner. I'm curious how GM actually stores curved paths, and knowing that might yield a solution.

After some tests I came up with the correct formula to calculate the path duration (for paths that only use straight lines) - only to find out that the real duration in GameMaker is always a bit longer than the theoretical duration.

The difference depends on the speed factors of the individual path points. If there are more points with low speed factors then the deviation from the theoretical duration becomes larger. Also, the longer the path, the larger the deviation. The reason must be in the internal mechanism with which the movement along the path is calculated.

All in all, I came to the conclusion that the built-in path system cannot be used to calculate reliable durations (especially not for paths with Bézier curves). So I ended up coding my own path system where the way I measure the duration is consistent with the way the instances are moved along the paths.

that would be my approach. because no matter the acceleration your gonna get the right answer.