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
 

ParodyKnaveBob

The Laughing Rogue
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
 

seanm

Member
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