How do I properly use the ease() function?

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

I am trying to ease values in and out and the function always returns me “1”

I’m declaring some variable in the upper scope like so

var my_var = 100

then in a game loop I run

my_var = ease(my_var, 1.1)
print(my_var)  #this is always 1

am i doing this wrong? I’m on godot 3.1

:bust_in_silhouette: Reply From: Zylann

Having a look at the doc: @GDScript — Godot Engine (3.1) documentation in English

Not only the doc is not clear which paramerers it describes, but the function itself is unusual.
The first thing to see is that the first argument s is expected to be between 0 and 1, and the output will also be between 0 and 1, which is pretty standard for easing functions. Then you can scale or lerp after that if you want a different output range. The curve parameter however isn’t obvious.

I made an issue a while ago about this function: Suggestion: the `ease` function should be split / reworked · Issue #10572 · godotengine/godot · GitHub

Here is how it looks visually:

Fantastic answer, still extremely useful one year and a half after you posted it.

I’m saving your diagrams for future reference.

RepMovsb | 2021-10-02 05:45

1 Like