• Editor
  • Change Playback Speed Per Bone Animation

Hello SpineFolk - Question : is there a way to force certain animation bones/changes to stay at a constant speed while
others can be adjusted via code?

Example 1: say I have an animation of a person who is blinking and swinging a whip around their head. All looks good
but now it has been decided that the whip swinging goes too slow at one spot of a game and too fast in another. In
code I change the speed, but now the eye blinks happen too slow/too fast.

Example #2: say I have an animated logo made up with a sign marque which has a border of 80 flashing lights. The sign
flies around the screen and zooms in/out. Now I need to change the speed on the fly but doing so changes the flashing
speed of the lights - which are timed to a musical beat.

Example #3: say I have the RoadRunner running down the road. The leg animation is just a quick spinning blur effect while
the head and neck animations gently move back and forth. Changing the playback speed to make the leg animation look correct makes the rest of the animations look wrong.

Thanks - ChzBoi

Related Discussions
...

Sure, use separate animations for blink and the whip, then set TrackEntry timeScale on the whip but not the blink.

Hi Nate - as a novice Spinerator, I may be missing a fundamental here.

Ok, in AS3 - I load my json,atlas, and png. Then set up my SkeletonAnimation, SkeletonData, and AnimationStateData. After all this is done, I set the state:

MySkeletonAnimation.state.setAnimationByName(0, "Animation1", true);

In that animation is both the blink and the whip.

What I've been doing (correct me if I am wrong!) is when I change animations, I set up a temp TrackEntry var and set the
state, timeScale, eventThreshold, etc. :

var tmpTE:TrackEntry;
tmpTE = MySkeletonAnimation.state.setAnimationByName(0, "Animation2", false);
tmpTE.timeScale = 1.5;
tmpTE.eventThreshold = 1;
tmpTE = MySkeletonAnimation.state.addAnimationByName(0, "Animation1", true, 1);
tmpTE.timeScale = 1;
tmpTE.eventThreshold = .75;

Are you saying I should make an animation named "Blink" and another named "Whip". The "Blink" will be a looping 2 second animation of the whole skeleton, but only the 'eye' bone/slot animates. Then in the "Whip" it will be 10 seconds long, of the whole skeleton but only the 'whipping' action bones/slots are animated. And then play them at the same time. Is this correct? Something like this:

var tmpTE:TrackEntry;
tmpTE = MySkeletonAnimation.state.setAnimationByName(0, "Blink", false);
tmpTE.timeScale = 1;
tmpTE = MySkeletonAnimation.state.setAnimationByName(1, "Whip", false);
tmpTE.timeScale = .5;

I feel like I must have totally skipped something in the tutorials vids! :-)

You got it right. :nerd: You can only control the time scale of a single animation, so you need to use separate animations. Actually you could dig through an animation's timelines, find the timelines for the whip but not the blink, and adjust the times so it takes long, but this is quite involved and it is much cleaner to use a separate animation for each thing you want to control. Another option is to adjust the animation in Spine, which might work for the whip but not for dynamic manipulation like in your other examples.

Just to clarify (as I swear I read that you can not have 2 'setAnimationByName' back to back, as the second removes the first) - as long as the TrackIndex of the setAnimation calls are different, it's all good to play at the same time. Most excellent!

If so, any conflicts between bone/slot animations would be resolved how? The threshold value?

Much thanks Nate!

(Apologies if this is explained in a tutorial - I swear I went through them all!)

Each track has a current track entry (which has an animation). It can also have track entries it is "mixing from", which are for mixing from one or more previously current entries to the current entry. You can play multiple animations concurrently by using separate tracks. The docs that cover tracks are here:
Applying Animations - Spine Runtimes Guide: Tracks
You can also use the Preview view to try your animations out on different tracks:
Preview - Spine User Guide
The coolest thing is that you can have preview running while you adjust your animations!

Cheers! :beer:

Thanks again Nate - totally missed that paragraph! Playing with Preview now - very cool!!
(now, add easing formulas to the graph and I'll be good!) :p