I have a moving platform which is being moved like this:
Vector2 currentPosition = rigidBody2d.position;
Vector2 movement = Vector2.MoveTowards(currentPosition, target, speed * Time.deltaTime);
rigidBody2d.MovePosition(movement);
velocity = (movement - currentPosition) / Time.deltaTime;
And I want to have the moving platform ease in and out of target speed when moving. Basically accelerate from starting position up to speed defined in speed parameter and then decelerate when near target position.
Someone told me to try using SmoothDamp instead of MoveTowards but I am a little perplexed with the behavior.
I've tried using it as follows:
Vector2 movement = Vector2.SmoothDamp(currentPosition, target, ref velocity, 0.1f, speed);
but no matter how much I modify the smoothTime the platform never goes near the set speed (5). It is mostly below 1 or around 1-1.1
What am I doing wrong here? How can I implement easing for my moving platform while still having it reach the set speed?