Topic was automatically imported from the old Question2Answer platform.
Asked By
Wysti
In the KinematicBody2D script I have these lines of code:
I am completely new to GDScript, and what I understood from the code above is that it increases the velocity.y by 30 thirty times or so every second. So I would like to have it stop increasing the velocity.y at some point.
If it is easier to just make the fall speed constant, instead of using the code I already have, that should work too.
First off, you should multiply gravity by delta, which is the time elapsed from the last frame, so your physics aren’t frame-rate dependent. Second, just do an if statement.
if velocity.y < some_number:
velocity.y += GRAVITY * delta
[+= is the same as adding the value directly to the variable]