eastern-flames/eastern flames/scripts/linear_approach/linear_approach.gml

6 lines
183 B
Plaintext

function linear_approach(val, goal, amount) {
if abs(val-goal) < amount val = goal;
if val < goal return val+amount;
if val > goal return val-amount;
if val == goal return goal;
}