• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker move a point along path

Z

zendraw

Guest
so i want to move a point in a path, in a loop
somthing like this
var i=0;
repeat (path_length)
{
path_position++;
}

but how to do it? you cant set a point manually on a path. path_position is read-only.
 

kburkhart84

Firehammer Games
I'm not sure exactly what you are trying to do. If you are trying to set something(an instance) to a specific point on the path(between beginning and end, which is 0 and 1), then you can just use path_position.

This function can be used to get or to set the position of an instance along a path. The value is normalised from 0 - 1, so if you set it to, for example, 0.5, the instance will be moved to exactly the middle of the path.
path_position is not read only, but it is a value between 0 and 1 only, so you can't just increment(++) it. It doesn't correlate with the points you used to define the path, rather it is simply between 0 and 1, with 0 being the beginning and 1 being the end of the path. The actual distance between any two values in there will depend on how long the path is.

Also, there is no path_length variable. There is a path_get_length() function you can use for this. If you are trying to figure out something to increment by, say to move 10 pixels along the path, then you can possibly use some math using the path length to figure out how much percentage to actually increment path_position to get the exact length. If you do 1 / path_length, it will give you a decimal value of how much to increment for each pixel of distance. You can then multiply that by how many pixels you want to move along the path, and then increment path_position by THAT amount to move that many pixels along the path. Of course that increment value will be different for each path.

EDIT*****

I should mention that the manual says that path_position is a function...it is actually a variable. @Nocturne you may want to fix this documentation page.
 
Top