How would I Lerp or interpolate this?

Is there a way I can Lerp or interpolate this so that the object doesn’t just “transport” to the new location but rather moves smoothly? I can usually fumble my way through JS but I am new to C# and everything I try throws an error. Here is my current code:

	void SetTransformY(float n){
		transform.position = new Vector3(transform.position.x, n, transform.position.z);
	}
	// Update is called once per frame
	void Update () {
		if(NetworkManager.rocketButtonState == 0){
			SetTransformY(1.0f);
		}
		else if(NetworkManager.rocketButtonState == 1){
			SetTransformY(0.2f);
		
		}
		else if(NetworkManager.rocketButtonState >= 2){
			SetTransformY(0.1f);


		}
	}

thank you

Try something like this for starters…

Update()
{
   SetTransformY(transform.position.y + speed * Time.deltaTime);
}

Where speed is a float you can try different values for. Multiplying it by deltaTime makes the distance moved each frame depend on how long it is since the previous frame, so the actual speed is constant. You could make your button presses alter the value of speed.