Assume you have a target that changes. Example:
// on average every 1000 frames, move the target
if (random(1000) == 0) {
// pick a value between 0 and 999
target = random(1000);
}
Now, I want to chase that value with both ease in and ease out. With just ease out a common solution is this
const kApproachFudge = 0.03;
value += (target - value) * kApproachFudge;
That only gives ease out though. Another might be to use a kind of arrive behavior
with acceleration and deceleration but that seems like overkill and is often fiddly meaning if your deceleration is not fast enough you'll overshoot the target. If you max speed is too high you might also overshoot the target. For example
I can sit there and just max force and max velocity and mass and deceleration but then it's so damn fiddley. If I want it to go faster I have to first adjust max vel, then maybe I have to adjust max force to it started quicker but then it will over shoot the target and I have to adjust other factors. I have to imagine this is a solved problem.
Is there a simple algorithm that ALWAYS gives good results?
note: I'm not looking for an ease in / ease out function between 2 fixed values. I have that in my toolbox and there are several answers here as well. There's probably an answer for this too but I didn't find it.