Global number t=0
Global number tt=0
Every tick
--- set t to (t+dt)%2
t<1
--- set tt to cubic(0,0.5,0.5,1,t)
t>=1
--- set tt to cubic(1,0.5,0.5,0,t-1)
Every tick
--- set X to lerp(A, B, tt)[/code:1i6tummh]
t goes from 0 to 2 every two seconds. You can adjust it so it goes at a different speed, or just make it stop at the end.
tt maps t to a curve. There are actually two curve parts. Going toward the target and coming back. The cubic expressions is where you define the shape. Change only the two 0.5 parameters. So for example an ease in/out could look like this:
Set tt to cubic(0, 0, 1, 1, t)