Game Guides > Game FAQ >  

How do you make objects that follow other objects in gamemaker

How do you make objects that follow other objects in gamemaker
If you want it to chase an object, i.e. cutting corners and going directly to the object, use a step event and then under move use step toward and stet:
x: "object you want to chase".x
y: "object you want to chase".y
speed: "how fast you want it to chase"
If you want it to follow the positions exactly, make 2 1d arrays (or "list" as GML calls it), one for x and one for y, and make the object that defines the positions push the values onto the top of the stacks, and have the following object pull from the bottom of the stacks then delete the bottom of the stacks. GML might do the last two steps at the same time, but I haven't used lists so you'll have to experiment a bit. NB: you'll have to use Advanced mode for this.