//object1.X <> ScrollX//
set object1. X
lerp(object1.x, destinationX, x*TimeDelta)
set ScrollX
lerp(ScrollX, destinationX, x*TimeDelta)
How do I change x*TimeDelta for both objects so that no matter how different their X coords are, they'll still end in the same X at the same time?
Please help?
Don't think too complicated.
So you want two objects with different distances to destinationX to reach that point at the same time. lerp is perfect for that, because wherever you start, as soon as the t-value reaches 1, both will be at destinationX. All you need to do is raising the t-value from 0 to 1 over the period of time you want.
If you want a number to grow over time, you add n * timedelta to it. The maximum value of t is 1.0. How long do you want it last until 1.0 is reached? 'n * timedelta' equals 'amount per second'
To have it last 2 seconds, you'd add 0.5 * timedelta (2 * 0.5 = 1)
To have it last 5 seconds, you'd add 0.2 * timedelta (5 * 0.2 = 1)
etc.
+ some condition
-> myT = myT + 0.5 * TimeDelta
-> lerp(object1.x, destinationX, myT)
-> lerp(ScrollX, destinationX, myT)
Just make sure, myT isn't raised anymore, after 1.0 is reached.