# How to get a pleasant path accelerating to a point

I am having trouble moving an object to a target position with a maximum acceleration limit.

If i just accelerate towards the target the object will fly in a doughnut a few times before hitting the target. example

If i first accelerate to reduce the vector rejection i get a nasty path directly away from the target and then a line straight to the target. example

Any ideas how to move in a natural human-like path?

edit

I now move in a circle at current speed with maximum acceleration until i am facing the target then accel towards it example1 example2

its not perfect but its quite predictable for players and i can calcuate time to reach target in constant time now (yey)

if anyone wants a break down of the math i can explain

• – Seth Battin Jul 12 '15 at 22:50
• @SethBattin i dont care about stopping at the point, just moving to it, final velocity is irrelevant for this problem – t123 Jul 12 '15 at 22:51
• Can you clarify what you meant by "doughhnut", then? That made me imagine that you were trying to stop at a point and wrongly orbiting it briefly. Or as that duplicate described it, oscillating. – Seth Battin Jul 12 '15 at 22:53
• @SethBattin added a couple of images – t123 Jul 12 '15 at 23:04
• Needs clarification for "natural" and "human-like". Nobody agrees on their meanings. – Anko Jul 12 '15 at 23:17

If you don't need a strictly physics based solution, bias and gain can be great for giving a nice organic (accel / decel) feel to a simple linear interpolation.

You could try setting a threshold from the target, and multiplying the object's speed by distance / threshold:

acceleration = distance / threshold

if (acceleration <= 1) {
speed *= acceleration;
}


Here's an interactive example I threw together quickly:

https://dl.dropboxusercontent.com/u/38185080/Flash/Examples/Deceleration.swf

Checking gradual movement will set speed to the acceleration value regardless of whether or not it is a value less than one. Without it checked, the speed will always equal the max speed unless it is within the threshold - it uses the same code displayed above, slightly modified:

if (gradual) {
speed = acceleration;
} else {
speed = maxSpeed;

if (acceleration <= 1) {
speed *= acceleration;
}
}


Now you all you do is add the object direction to its position and multiply it by speed:

position += direction * speed;