How do you find an objects position in Game Maker?

babin101 picture babin101 · Jan 15, 2013 · Viewed 67.1k times · Source

I am making a game in Game Maker right now and cannot figure out how to get an objects exact position and have another object move to that position. Can someone please help me?

Answer

paul23 picture paul23 · Jan 16, 2013

To get an object's position simply use

xpos = instance.x;
ypos = instance.y;

where instance is the instance id (gained through some method, object id can be used if the instance is the only instantiation of the object).

To start moving towards a position you should set the speed & direction:

direction = point_direction(x,y, instance.x, instance.y);
speed = WANTEDSPEED;