Move GameObject between two points using Scrollbar

Hey Unity Pros,

I want to make a UI Scrollbar move my GameObject (in this case the Camera) between two points in 3D space. So for example if scrollbar.value is 0 than the Camera is at point A and if the value is 1 than its at point B. And also everything in between.

I’ll look forward to your help and thanks in advance!

Use Vector3.Lerp to move the camera’s position between two points.

public Vector3 pointA, pointB;
public float lerpAmt; // replace this with scrollbar.value
void Update () {
	Camera.main.transform.position = Vector3.Lerp(pointA, pointB, lerpAmt);
}

You can just make a script which polls the state of the scrollbar in every update() if this is your problem.

[SerializeField]
private Vector3 posA;
[SerializeField]
private Vector3 posB;

void Update()
{
      float scrollBarValue = ...; //I have forgotten how to poll this sorry :D

      target.transform.position = posA + ((posB - posA) * scrollBarValue);
}