Need Help Aiming Smoothley

So I have been playing around with some Javascript to try and get my gun to smoothly aim, but I can’t seem to get it to move from HipPos to AimPos smoothly. Any help would be awesome!

Here’s the Script:

var HipPos : Vector3;
var AimPos : Vector3;
var TimeDamp = 3;

private var MainCam : GameObject;

function Start(){
	//setting the HipPos at the game start
	transform.localPosition = HipPos;
	MainCam = GameObject.FindGameObjectWithTag("MainCamera");
}
function Update(){
	if(Input.GetMouseButtonDown(1)){
		//if right click move the gun to main cam
		transform.localPosition = Vector3.Lerp(AimPos, HipPos, TimeDamp / 150);
		//change FOV to align sights correctly
		MainCam.camera.fieldOfView = 20;
	}
	if(Input.GetMouseButtonUp(1)) {
		// if right click is released return it to HipPos
		transform.localPosition = Vector3.Lerp(HipPos, AimPos, TimeDamp / 150);
		//put the camera's FOV back to 60
		MainCam.camera.fieldOfView = 60;
	}
}

The third parameter of Lerp basically means “What percent of this Lerp should I calculate?” with 0.0f meaning “starting point” and 1.0f meaning “ending point”. Thus, 0.5f is “Half way between” etc.

As such, you need to need to update the percent each frame according to your desired animation speed - something like percentDone += (1 / timeToAimSeconds) * Time.deltaTime and then use percentDone as the final parameter. (You’ll -= instead of += when putting it away). You also will need to clamp the variable to never go below 0.0f or above 1.0f.