1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Point to move Sprite animation

Discussion in 'Programming' started by Donnyyyyy, Feb 14, 2020 at 8:57 AM.

  1. Donnyyyyy

    Donnyyyyy Member

    Oct 18, 2019
    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!
  2. JackTurbo

    JackTurbo Member

    Oct 19, 2016
    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

Share This Page