Moving an object towards another accelerating speed?

hello I have an object that moves towards the player and I want the object to start slow and speed up as it gets closer to the player so I thought of using the tween behaviour on the object but I can’t get any of easing “in” options to work?

Hi is better to do that calculating the distance between your object and the player then apply different forces to the object, like
if object distance to player > 200
Apply to object 100 on X
if object distance to player < 150
Apply to object 50 on X
if object distance to player < 10
Apply to object 30 on X

1 Like

I used a couple of the ease in options and it worked, but I am not sure how fast you want the acceleration to be.

The option presented by @UlisesFreitas gives you a lot of control over the way the object will accelerate.

thanks for the reply I tried your solution but the player is always moving around so there are times when you can be close then move far away from the object which causes it to slows down again before it catches up to the player and the object speed increments are not smooth like the tween behaviour.

thanks I’m trying this solution and it works for the most part :sweat_smile: the only issue I’m having is the object is moving to the players position and not towards the player which causes the object to stop at where the players position was when the object was created and not where the player is currently?

You could try using the HomingProjectile extension:

http://wiki.compilgames.net/doku.php/gdevelop5/extensions/homing-projectile/reference

Or you could use the lerp() function, but that makes objects move fast at first, and slow as they approach the destination.

solved! I’m sure there is a better way to do this but I got it to work using a timer.

events

1 Like