GMS 2 Pathfinding (GMS2) (SOLVED)

Discussion in 'Programming' started by KPJ, Feb 5, 2019.

  1. KPJ

    KPJ Member

    Joined:
    Jan 19, 2019
    Posts:
    115
    Hi everyone! I am making a top down stealth game where I want the enemy to chase the player (and look at the player) if it is in within range. I don't want to use move_towards_point or mp_potential_step / mp_potential_step_object as they have jittery movement.
    So, I tried Heartbeast and Cameron Penner tutorials of pathfinding using grids. this works all fine, however when I try and make the enemy face the player, the grid pathfinding becomes jittery and crazy again. Does anyone know another way for enemy pathfinding?
    Thanks!
     
  2. Danei

    Danei Member

    Joined:
    Mar 23, 2018
    Posts:
    278
    How are you making them face the player? If you manually draw the sprite at the appropriate angle, without changing the inbuilt angle or scale variables, you ought to be able to draw the sprite in basically any way without affecting pathfinding at all.
     
  3. KPJ

    KPJ Member

    Joined:
    Jan 19, 2019
    Posts:
    115
    Danei I am using:
    direction = point_direction(x, y, oPlayer.x, oPlayer,y);
    image_angle = direction;
     
  4. RefresherTowel

    RefresherTowel Member

    Joined:
    Jul 13, 2016
    Posts:
    1,184
    Code:
    image_angle = point_direction(x, y, oPlayer.x, oPlayer,y);
    
    FTFY
     
    KPJ likes this.
  5. KPJ

    KPJ Member

    Joined:
    Jan 19, 2019
    Posts:
    115
    RefresherTowe thanks. It worked but I still don't have smooth movement, and the face toward player has become a bit off as well.
     
  6. RefresherTowel

    RefresherTowel Member

    Joined:
    Jul 13, 2016
    Posts:
    1,184
    That line I posted is the -only- thing you need to make the enemy face the player. If you have changed the actual pathfinding code while trying to attempt this, you should change it all back to how it originally was (as you said in your post, it all worked fine to begin with, just the facing thing was wrong).
     
    KPJ likes this.
  7. KPJ

    KPJ Member

    Joined:
    Jan 19, 2019
    Posts:
    115
    RefresherTowel it works now! Thanks for your help!
     
    Last edited: Feb 5, 2019
    RefresherTowel likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice