+3 votes

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

in Engine by (38 points)

1 Answer

+7 votes
Best answer

Having a look at the doc: https://docs.godotengine.org/en/3.1/classes/[email protected]#class-gdscript-method-ease

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: https://github.com/godotengine/godot/issues/10572

Here is how it looks visually:
enter image description here

by (29,036 points)
edited by

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

I'm saving your diagrams for future reference.

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.