How do I create a rubber band effect on a camera forward movement?

Hello everybody,

In my VR scene the camera is a player and moves forward on button press, using transform.Translate().

However once the button is not pressed the camera immediately stops .

I’d like the camera to stop very smoothly, with slight rubber band effect, meaning going slightly forward and then back.

This is my script for moving forward:

var direction = mainCamera.gameObject.transform.forward * maxSpeed * Time.deltaTime * (accelerationSqrMagnitude/10);

 camHolder.Translate(direction, Space.World);

Thank you

Not sure how to do the rubberband effect, but smooth stopping is easy


camHolder.Translate(direction, Space.World);


float delay = 2; // 2 seconds
float speed = 4;

camHolder.postion = Vector3.Lerp(camHolder.postion, camHolder.postion + direction * speed * Time.DeltaTime, delay);