• 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!

Following a line Without using paths?

A

ag07

Guest
How can I get an object to follow a line, Without using paths? I want the object to follow lines formed from random coordinates, based on mouse clicks. So a path laid out before the game runs is not suitable. Is using paths the only practical option?

Thanks
 
P

ParodyKnaveBob

Guest
Howdy, ag07,

Did you look up "Paths" in the manual's index? The last bulleted link on the page should say "Changing Paths," and that page reads, "In GameMaker: Studio you are not just limited to the paths that you make using the Path Editor. There are a number of functions that can be used to manipulate and change those paths at run-time, or to even create new ones and then change and manipulate those," before listing a bunch of functions that should interest you.

The manual is your friend. I hope this helps,
Bob $:^ ]
 

TheouAegis

Member
Store each mouse click as a waypoint and use the direction from the current position to the next waypoint as direction and set the unit's speed.
 
A

ag07

Guest
Thanks to both of you. I guess I missed that last section of the paths manual..

"Store each mouse click as a waypoint"....how do I do this? Please give an example in code

thanks
 
S

seanm

Guest
direction=point_direction(x,y,waypointX,waypointY)

just store some points in an array and load them into that
 
A

ag07

Guest
if (array_pos >= 1) { //array_pos shows current element of array called "point"
image_angle = point_direction(x,y, point[array_pos - 2], point[array_pos - 1]);
direction = point_direction(x,y, point[array_pos - 2], point[array_pos - 1]);
speed = 1;
}
}

The above code works.

Thanks again
 
Top