UDim2:Lerp() not working properly?

So I’m currently testing my dynamic crosshair and I’m pretty confused with this problem

This is my code, I’m pretty sure it should work work. (crosshair.Up.Position is {0.5, 0},{0, 0})

local upPost = crosshair.Up.Position:Lerp(UDim2.new(0.5, 0, -1, 0), deltaTime)
crosshair.Up.Position = upPost

And then if I’m ‘lucky’ enough it’ll function as it’s supposed to be. I’m really confused

(This code is inside a RenderStepped loop)

Its supposed to go from the white box to it’s goal. Instead it comes from OFF the screen to its goal as showed:


Thanks in advance!

How do you want the crosshair to actually behave? Should it:

  1. Move towards its goal at a consistent speed?
  2. Always remain at a fixed percentage distance between its start position and the goal?
  3. Move quickly towards its goal at first, but slow as it gets closer?

I’m pretty sure lerping is for cframes, have you tried using TweenService?

If it’s a gui object, you can just use crosshair.Up:TweenPosition(UDim2)

1 Like

It’s basically going to its goal in the wrong direction. It’s supposed to go from 0 to -1 but sometimes it goes from -3 to -1 for no reason. (example showed above)

I prefer to not use TweenPosition because it’s going to be a dynamic crosshair and the values will be changed quite frequently