• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Delta time and easing functions

W

whitey

Guest
Hi all,
Ive been successfully messing around with some easing functions using an incremental timer however I would like to use delta time instead but results are not precise.

I have been using this script:

/// @description ease_linear(time, start, change, duration)
/// @param time
/// @param start
/// @param change
/// @param duration

return argument2 * argument0 / argument3 + argument1;

and calculating delta time like:

var dt = delta_time / 1000000;

should I be doing something else?
 

FrostyCat

Redemption Seeker
That's correct as long as it is cumulative and proportional to time and duration. Here's an example:

Create:
Code:
image_alpha = 0;
fadein_time = 0;
fadein_duration = 3;
Step:
Code:
fadein_time = clamp(fadein_time+delta_time/1000000, 0, fadein_duration);
image_alpha = ease_linear(fadein_time, 0, 1, fadein_duration);
 
W

whitey

Guest
Thank you, I was not clamping which may have caused the bad results. I’ll give that a try when I get home
 
W

whitey

Guest
Just tested and clamping the elsapsed time fixed my issues, thanks again.
 
Top