How would I convert the below lerp code to Godot 4?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hammo

How would I convert the below code in Godot 4 to achieve the same result?

func apply_horizontal_deceleration(delta : float) -> void:
velocity.x = lerp(0, velocity.x, pow(2, -40 * delta))

Thnak you!

What results are you getting? Neitherlerp nor pow functions should not differ between versions.

aXu_AP | 2022-09-17 04:27

:bust_in_silhouette: Reply From: Jafango

Your problem is that you should be using lerpf instead of lerp
for example, your code should look like:

func apply_horizontal_deceleration(delta : float) -> void:
velocity.x = lerpf(0, velocity.x, pow(2, -40 * delta))

I struggled a lot with this problem aswell and I found this works

thanks for your answer! it helped me

RodryArk | 2022-12-02 12:31