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 How to stop sprite from shaking when following the player object?

Discussion in 'Programming' started by Doober, Jun 22, 2019.

  1. Doober

    Doober Member

    Joined:
    May 10, 2019
    Posts:
    7
    I have an object set up to specifically follow the player object around my game and for some reason the follower object is always shaking when it follows the player and when the player stops moving. If anyone could help me figure out why it keeps doing this and to solve this issue I would be extremely great-full.

    P.S. The follower object is using a coded move_towards_point system in order to follow the player around the game.

    P.P.S. I only want the follower object to stop shaking and to stop moving altogether when it collides with the player, the point doesn't matter to me.

    P.P.P.S. I have tried the collision event with the follower object but whenever it collides with the player object they both just get stuck on each other and I have no clue why.


    Thanks for all the help! :3
     
  2. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,435
    Limit speed of move_towards_point to min(your peak speed, point_distance(x, y, player.x, player.y))
     
  3. Doober

    Doober Member

    Joined:
    May 10, 2019
    Posts:
    7
    I'm sorry but do you think you could explain in a bit more detail? I don't really understand what you mean by that.
     
  4. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    7,038
    What he means is that when the distance between the x/y position and the go-to x/y position is less than the maximum speed of movement, use the distance value instead of the maximum speed so the instance "eases" towards the position. For example:

    Code:
    var _dist = point_distance(x, y, obj_Player.x, obj_Player.y);
    var _spd = min(_dist  / 5, 10); // this will set the speed to between 0 and 10 depending on the distance from the go to position
    move_towards_point(obj_Player.x, obj_Player.y, _spd);
     
  5. Doober

    Doober Member

    Joined:
    May 10, 2019
    Posts:
    7
    So all these variables would be placed in the Create Event correct? Also what do you mean exactly by "eases" because no one in the game can see the follower object, I just want it to stop shaking when it comes into contact with the player object.
     
  6. TinyGamesLab

    TinyGamesLab Member

    Joined:
    Jun 21, 2018
    Posts:
    147
    No, this code should go on the step event.
    They mean that your follower object is overshooting the player when it gets to near, so it tries to move backwards but ends up overshooting again since the amount it moves per step is higher than the distance to the player.
     
  7. Doober

    Doober Member

    Joined:
    May 10, 2019
    Posts:
    7
    Thank you all for your responses, they have all greatly helped me and I hope the best for you all! :3
     

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