• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Make player face the right way while pathfinding

Bee

Member
Hello all,
I have built a game where the player targets the nearest enemy and uses Game Maker's pathfinding to make his way there on his own. The problem is that he doesn't face in the direction of his movement but faces his target. What do I use for his direction for his facing (right, up, left, down)?
 

NightFrost

Member
I forget, but didn't motion planning automatically set instance direction to correct value? If so, you can take it and:
Code:
Facing = round(direction / 90);
Where Facing 0 and 4 is right, 1 is up, 2 is left and 3 is down.
 

NightFrost

Member
Also, even if motion planning does not set direction, you can figure it out by doing after mp movement:
Code:
Dir = point_direction(xprevious, yprevious, x, y); // Calculates direction from previous position towards current position
 
Top