So I’ve been trying to figure out how to control the position of a UI button, but everything I’ve found online seems to not work… Here is my code, any help is graciously appreciated!! Thank you!

```
void LateUpdate () {
if (Input.GetKeyDown (KeyCode.R))
RPressed = !RPressed;
if(RPressed)
Inventory.anchoredPosition = Vector3.Lerp(new Vector3(currPos.x, currPos.y, 0), new Vector3(1126, currPos.y, 0), Time.deltaTime);
else if (RPressed == false)
Inventory.anchoredPosition = currPos;
}
```

~WM

Does “currPos” changes on every frame? If it doesn’t your lerp function always returns the same value (which is really close to (currPos.x, currPos.y, 0)) so you’ll set the anchordPosition to the same value every time.

If “currPos” doesn’t change then your 3rd parameter should be incremented on each frame, Lerp will return the first parameter if the 3rd is zero, the second parameter if the 3rd is 1, and an interpolated value between both parameters if the 3rd is greater than 0 and smaller than 1.

Maybe this helps:

```
float elapsedTime = 0;
void LateUpdate () {
if (Input.GetKeyDown (KeyCode.R))
RPressed = !RPressed;
if(RPressed) {
elapsedTime += Time.deltaTime;
Inventory.anchoredPosition = Vector3.Lerp(new Vector3(currPos.x, currPos.y, 0), new Vector3(1126, currPos.y, 0), elapsedTime);
} else if (RPressed == false) {
Inventory.anchoredPosition = currPos;
elapsedTime = 0;
}
}
```

That code will “lerp” from one point to another in 1 second, you can change the speed using a multiplier (elapsedTime * 2 be twice as fast, it’s take 0.5 seconds).