Last active
July 1, 2022 11:52
-
-
Save chasepeck/64b6970133f9bcc7e9f3de3f41d8c84f to your computer and use it in GitHub Desktop.
AC system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ac(_curve, _channel, _step, _backwards = false, _frame = 0, _disabled = false, _mn = 0, _mx = 1, _autoreset = true, _autodisable = true) constructor { | |
curve = _curve; | |
channel = _channel; | |
step = _step; | |
backwards = _backwards; | |
frame = _frame; | |
disabled = _disabled; | |
mn = _mn; | |
mx = _mx; | |
autoreset = _autoreset; | |
autodisable = _autodisable; | |
static update = function() { | |
if(!disabled) { | |
if(!backwards) | |
frame = clamp(frame + step, mn, mx); | |
else | |
frame = clamp(frame - step, mn, mx); | |
} | |
if(frame == 0) { | |
if(autoreset) backwards = false; | |
if(autodisable) disabled = true; | |
} | |
value = animcurve_channel_evaluate(animcurve_get_channel(curve, channel), frame); | |
} | |
static reset = function(maximum = false) { | |
if(!maximum) frame = mn; | |
else frame = mx; | |
} | |
} | |
function ac_updateall(arr) { | |
for(var i = 0; i < array_length(arr); i++){ | |
arr[i].update(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment