Animation optimization & fixes

We’ve enabled some internal changes in our animation system on desktop just now.

Specifically:

  1. Much faster implementation (5-10x faster depending on the complexity of the rig)
  2. Pose.MaskWeight is no longer supported
  3. Some blending bugs have been fixed (Polyguns! \o/ @x_o)
  4. Blending behavior has changed in some cases (Edit: This is no longer the case - behavior closely matches what used to be the case)
This is no longer relevant - please disregard The most likely change that you may witness is #4. Previously, if you played 5 looped animations of the same priority with weight 1, we'd just use the last one you played. Now we blend all animations with the same priority together with a weighted blend - so if you play 5 animations with weight 1, they all have equal weight so the result is (A+B+C+D+E)/5. The way to resolve this is to play the animation you want to see blended "over" in a higher priority layer.

One prominent case where #4 may appear is if you forget to stop your animation tracks and just play new ones. Now you’ll see a blended motion that will look weird - however, please note that not stopping your looped animation tracks is really bad for performance since we never stop them for you! So this is something you should fix anyway (you can check which animation tracks are playing using http://wiki.roblox.com/index.php?title=API:Class/Humanoid/GetPlayingAnimationTracks)

Sometimes this will happen if you replace our default Animate script by removing the old one and reparenting the new one. In this case there may be animations that the old script has started but are still playing. A better way to do this is to put your custom script into the StarterPlayer/StarterCharacterScripts and naming it ‘Animate’. This will automatically replace the default one without even starting it.

Please comment on this thread if you see any issues with the update.

8 Likes

The smores in Camp Nexus no longer reach my face.
blob.png
I don’t remember how I set up the priority though. I will post more when I get home and can actually investigate it.

Every single animation my characters use, regardless of whether they’re custom or default, only animates halfway-ish now.

Default jumping animation - arms only reach half height, overall limb ovement is greatly lessened.

Default sitting animation - arms and legs only fold halfway

This probably means you are playing another animation that was previously being overridden by the default animation.

1 Like

With this change, I think we need more priority levels for animations. Prior to the change it wasn’t so much of a problem because if you played animations with the same priority, the latest animation would in theory be priority level current+1, allowing you to have infinite levels of priority – you could keep playing animation on top of animation. With this update, if you want that behavior, you either have to increase the priority level, or keep track of the order all animations are played in + stop all current animations playing when a new one is played at the same priority level + manually keep track of their current play time + whenever the current animation stops, find the last played animation that is still running and start it at stoppedTime+elapsedTime. The latter of the two is a lot more to do than was previously needed, and if someone is using the default ROBLOX animations (most games), they only have three priority levels to work with for the former approach. Core’s (highest priority) enum number is 1000, so there should be plenty of room to expand.

4 Likes

well this broke a whole lot of my animations

cool

4 Likes

I agree that we need more priority levels.

Keeping playing animation on top of animation is a bad habit though - this increases (potentially infinitely!) the number of concurrently played animations. We actually had a problem like this with a toolbox model where the game would just get slower and slower over time.

1 Like

All I did was copy a custom animation into the stock Animate LocalScript, so I honestly have no clue what needs to be changed to fix this.

Hmm. Which game is this?

I can drop my Animate script here if you want.

Yeah, that’d help.

NewAnimate.rbxm (6.8 KB)

So as far as I can tell this is what’s happening:

When you replace the default Animate script it has already started some animations - usually idle. So when your new script destroys the old one it neglects to stop the animations the old script has started.

I’m not really sure if there’s a better way to replace the default Animate script (cc @CodeWriter) but a possible workaround would be to do this after you get the Humanoid object in your new script:

for _,v in pairs(Humanoid:GetPlayingAnimationTracks()) do v:Stop(0) end
1 Like

Noted. I’ll play with that tomorrow and report back.

You can replace the starting Animate script simply by putting your custom script into the StarterPlayer/StarterCharacterScripts and naming it ‘Animate’. This will replace the default script that gets added to all Humanoids with your new script before either starts.

6 Likes

This solved my issue, thanks!

Added info about correct way to replace Animate script to the OP, thanks @CodeWriter!

Would be nice to have the option to turn off Blending mode in my game and revert it back to the previous version.
It made a pretty big impact on my game and the fans don’t like it

But you can fix it yourself by stopping animations when you override them with another, and then restarting them when necessary. Or using different priority levels, if you weren’t already.

It should be pretty easy to change the game code to use different priorities. If it’s hard for some reason can you describe your use case?