Legacy GM How to stop sprite from shaking when following the player object?

Doober

Member
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
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Limit speed of move_towards_point to min(your peak speed, point_distance(x, y, player.x, player.y))
 

Doober

Member
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.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
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);
 

Doober

Member
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.
 
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.
 
Top