Help with move_toward()

Godot Version

4.2.1

Question

for the three inputs required for move_toward(), what are they? in the engine it said “from: float, to: float, Delta: float” but what do each of them actually mean? or what are the three requirements to be given to it?

That’s simple, lerp() uses weight as the third parameter, while move_toward() works with delta. Let me explain on a simple example:

print(lerp(0, 10, .05))  # prints 0.5
print(move_toward(0, 10, .05))  # prints 0.05

Lerp calculates the difference (10 - 0) and multiplies it by 0.05. The result is 0.5.

Move_forward just adds the delta value to the first argument, but never goes over the second one. 0 + 0.05 = 0.05.

Hope that helps.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.