Skip to content

Instantly share code, notes, and snippets.

@apokellypse
Last active April 9, 2019 03:05
Show Gist options
  • Save apokellypse/1ec30d0841f11de38c5f54e1d30cb405 to your computer and use it in GitHub Desktop.
Save apokellypse/1ec30d0841f11de38c5f54e1d30cb405 to your computer and use it in GitHub Desktop.
Stagger Keyframes Given Existing Animation
// stagger_keys.mel (using .m to get gist syntax highlighting)
// author: Kelly Yu
// I have 124 keys that look like bunny_slice_$i_translateY where $i ranges from 001 to 123
for ($i = 1; $i < 124; $i++) {
string $formatted;
// format number so that it is at least 3 digits long
if ($i < 10) {
$formatted = "00" + $i;
} else if ($i < 100) {
$formatted = "0" + $i;
} else {
$formatted = "" + $i;
}
string $name_of_key = "bunny_slice_" + $formatted + "_translateY";
// shift existing keyframe by $i units, which introduces a stagger when applied to all keyframes
keyframe -e -iub true -r -o over -tc $i $name_of_key ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment