0 votes

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!

Godot version 4.0 Beta 1
in Engine by (26 points)

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

1 Answer

+1 vote

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

by (16 points)

thanks for your answer! it helped me

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.