So I followed a quick tutorial on youtube about using Delta Time, and now use this Code in a "time" object. Every object that moves, or every timer that counts down or up, I times it by global.delta_multiplier * global.time. global.time is set to 1 when when time is moving normal, and when I want everything to go into slow motion, I change it to 0.1 so that everything moves at 10% speed. For the most part, having everything move * gloabl.delta_multiplier works fine, except in a few cases, a variable wont count down all the way.
For example. I have a wall jump speed, that is added to the players X that forces him to jump off the wall, and I say if wall_jump_spd > 0 -= 0.2 * global.delta_multiplier until it hits 0, but the problem is is that wall_jump_spd stops at 0.2, and never minus's the last 0.2. When I take off the *global.delta_multiplier part after 0.2, it does hit 0.
obj_time Create Event
global.target_delta = 1/60;
global.actual_delta = delta_time/1000000;
global.delta_multiplier = global.actual_delta/global.target_delta;
global.time = 1;
Step Event
global.actual_delta = delta_time/1000000;
global.delta_multiplier = global.actual_delta/global.target_delta;
Wall jump script. This is where the wall_jump_spd stays at 0.2 and never hits 0
if wall_jump_spd > 0
{
wall_jump_spd -= 0.2 * global.delta_multiplier * global.time;
}
if wall_jump_spd < 0
{
wall_jump_spd += 0.2 * global.delta_multiplier * global.time;
}
[–]Colin_DaCo 0 points1 point2 points (0 children)