• Editor
  • Fewer Keyframes = Better Performance, Right?

...right?

I've been operating under the assumption that the fewer keyframes used in an animation, the better performance I will end up with. So if I have a set of keys at frame 8, and set of keys for different bones at frame 10, I would be able to increase performance by perhaps moving all of these keys to frame 9? Still the same number of keys total, but they are now firing at the same time.

Is this correct?

Related Discussions
...
  • تم التحرير

The number of keys doesn't make much of a difference unless you are instantiating A LOT of that skeleton and consequently having to play that same animation a lot at once.

Curve keys vs linear keys probably makes more of a difference in performance. But even then, only when you have like a ton of them.
Every skeleton is different so you always have to test it with the skeleton you are using and with your target device.

Only keys that "fire" are event keys. All other key types are interpolated/extrapolated


meaning it doesn't matter if all the keys are on the same frame.

For each timeline, a binary search is done to find the two keys playback is between. So it doesn't matter if different timelines have keys on the same frame. The number of keys does affect the search, but you won't see a performance difference from that. Using fewer timelines makes a difference, because it avoids an entire search. Still, avoiding bone and especially vertex transforms is more important for performance.
Metrics - Spine User Guide: Performance

I think it's also worth pointing out that "premature optimization" is generally bad. When you're animating, be creative, don't be optimizing 🙂
You will be able to optimize your animations at the end, if you need it. But like Nate mentioned, bones and vertex transforms are way more important to look at.
You'll find a link to this Key Frames - Spine User Guide: Clean Up on the page Nate linked as well, but in case you missed it, Spine already has a few tools to clean up animations slightly.

Okay guys, thanks for the great info, definitely helpful!