GameMaker Point to move Sprite animation

D

Donnyyyyy

Guest
Hey. Trying to make a click to move type of game in Game Maker 2. (GML) I've managed to program the moving itself. But need help programming the character changing sprites based on the direction it is moving in.

The character has 4 directions. Left, right, Up and Down. Is here any way to make it use the Up walking animation if you click somewhere above it? Same with down, right and left.

This is the Step event I use for its point to click moving.

"
if (xx != mouse.none && yy != mouse.none) {
move_towards_point (xx,yy,spd);
} else {
speed = 0;
}

if (distance_to_point(xx,yy) < spd + 2) {
xx = mouse.none;
yy = mouse.none;
}
"



If anyone would like to help me with this id appreciate it ALOT!
 

JackTurbo

Member
Really if you want point and click movement you probably want to be using proper path finding.

As for animation control rather than base it off where you clicked I'd suggest basing it off where the object is moving. If you were to use paths then the objects direction built-in variable will be updated when ever it's moving and you could use that.

The yoyo blog has a great run down on path finding here: https://www.yoyogames.com/blog/459/dynamic-mp-grids
 
Top