Hey! I just started earning gdscript/godot a couple months ago, so if anyone sees this and has corrections to make, PLEASE do so.
It can be seen in the godot docs that the third argument passed to the lerp method (float weight) actually represents its portion of the way between the first two arguments. For example lerp(5, 9, 0.75)
would return a value of 8.
This can be compared with move_toward
in which the third argument passed (float delta) represents the difference between the first argument and the value returned (in the direction of the second argument). For example move_toward(5, 9, 0.75)
would return 5.75.
In your code, using lerp. Assume MAX_SPEED = 12, ACCELERATION = 2 and that I am holding down the "RIGHT" input key.
First lerp(0, 12, 2)
will return 24 to velocity.x
Next lerp(24, 12, 2)
will return 0 to velocity.x
Again, lerp(0, 12, 2)
will return 24 to velocity.x
Hypothetically a decent effect could be created using your lerp code, so long as ACCELERATION is less than zero, though your position curve would look more like sqrt(x) than x^2 (concave down, rather than up) which would be pretty unnatural AND you would never technically reach MAX_SPEED, just infinitely approach it. An intermediate effect with an S shaped curve might be a really interesting thing to explore!
I hope I was of some help to you. Good luck!