1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Following Party Members Question

Discussion in 'Programming' started by IncuTyph, Nov 13, 2019.

Tags:
  1. IncuTyph

    IncuTyph Member

    Joined:
    Oct 18, 2019
    Posts:
    10
    So I'm trying to have some following party members in my game. It's an RPG. Wanted to have a sort of caterpillar following system for party members (think Earthbound or Pokemon Mystery Dungeon). I have been using a ds_queue on the follower object, and it works for the most part. He will get stuck behind things and then snap back to position. Is there a way to make him follow smoother using a ds_queue or should I try an alternative method? I also want to know if there's a way to 'pass' through the party member as well to prevent being stuck in a corner because of him being right next to the player.

    Here's the code I have for my follower:
    Code:
    ///CREATE EVENT
    //set up a que
    Following_que = ds_queue_create();
    
    ///STEP EVENT
    ///Movement while in party
    if ppos2 = obj_frisk_party //ppos2 is the p(arty) pos(ition) he's in. Denotes he's supposed to be second in the party line
    {
         if obj_player.phy_position_x!= obj_player.xprevious
             {
                 ds_queue_enqueue(Following_que,obj_player.phy_position_x)
                 ds_queue_enqueue(Following_que,obj_player.phy_position_y)
              }
    }
    
    if ds_queue_size(Following_que) >= 30
    {
        phy_position_x = ds_queue_dequeue(Following_que)
        phy_position_y = ds_queue_dequeue(Following_que)
    }
    
    
    depth = -y;
    As I said, he follows, but gets stuck behind things and teleports to get back behind the player. I've tried tightening the queue to less than 30, but that definitely doesn't help. There is no grid-based movement BTW, just like in Earthbound. I plan to have no more than 3 party members in the line at any time.

    Any help is appreciated!
     
  2. Fabseven

    Fabseven Member

    Joined:
    Oct 7, 2016
    Posts:
    356
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,125
    Is it free-roaming or tile-based roaming? If it's tile-based, just store the player's current tile/cell in the follower and have the follower move toward that tile/cell with the player's current speed. So if the player's not moving, the follower doesn't move; but if the player is moving, the follower walks to the player's previous position. For multiple followers, do the same thing, but have each follower store its position in the next follower.
     
    Fabseven likes this.
  4. IncuTyph

    IncuTyph Member

    Joined:
    Oct 18, 2019
    Posts:
    10
    It's free roaming.
     

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