So I learned about linear interpolation and now I want to fiddle with this idea.
Given lerp formula from godot docs, which is interpolation = A + (B - A) * t
, I want t
to change its value from A
to B
and once it reaches B
, it changes its value from B
to A
, then the loop repeats.
So I've come up with this:
extends Label
var t = 0
var a = 10
var b = 20
func _process(delta):
t = wrapf(t + delta, -1, 1)
text = str(a + (b - a) * abs(t))
So the question is, as the title suggests, is there a more efficient way to create this loop behavior?