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
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

GMS 2 Point to move Sprite animation

Discussion in 'Programming' started by Donnyyyyy, Feb 14, 2020.

  1. Donnyyyyy

    Donnyyyyy Member

    Joined:
    Oct 18, 2019
    Posts:
    3
    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

    Joined:
    Oct 19, 2016
    Posts:
    837
    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