• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Flipping sprites based on direction while using move_towards_point?

Ache

Member
I'm working on enemies for my game and I want something that will move towards the player, so obviously I used move_towards_point. The problem is that I don't know how to flip sprites while using move_towards_point, but I also don't know what other way to make them follow the player.

obj_enemies Create event:
GML:
switch(etype)
{
    case 0:
    isboss = false;
    
    //behaviour
    move_towards_point(obj_player.x, obj_player.y, 0.5);
    break;
}

if hp <= 0
{
    instance_destroy();   
}
obj_enemies Step event:
GML:
switch(etype)
{
    case 0:
    isboss = false;
    
    //behaviour
    move_towards_point(obj_player.x, obj_player.y, 0.5);
    break;
}

if hp <= 0
{
    instance_destroy();   
}
 

TsukaYuriko

☄️
Forum Staff
Moderator
move_towards_point modifies the built-in movement variables, most notably in this case hspeed and vspeed. You can compare against these to flip the sprite (e.g. update image_xscale according to whether hspeed is positive or negative).
 
Top