Additive animations distorted

I have a glb file with animations on it. Face animations (which i want it to be additive) and body animations (which i want to blend between each other). Everything is working fine except when i am changing animations fast, or i am fast clicking on, for example, Wave animation, then face get distorted.

cc @PatrickRyan

@Veljko, after digging into your scene I am seeing why you are getting some strange combinations of the expression morph targets when quickly clicking one of your UI buttons. This has to do with the fact that you have enabled blending, have multiple clips playing on the morph target influences at the same time, and have additive blending applied to the morph target animations.

If you disable the animation blending and change nothing else about your scene, the problem goes away. What is happening, however is a little more complicated so you may need some guiderails if you want to use additive blending for additional face morphs for visemes or emotions.

All of your animations seem to have some keyframe data on many of your morph target influences, so by adding in the idle blendshapes or talking blendshapes animations, you are getting influences of both the bode animation (for example idle) and the face animation (for example blendshapes talking) adding together. When you click on one of the UI buttons, you are telling the current body animation to stop and a new body animation to start while blending between the two clips. While this change in the body animation is happening the face animation continues without stopping.

This means that the face animation is in a different point every time you click a UI button, the body animations blend, interpolating between the two motion clips and the current time of the face animation is added to any influence weights of the body animations. Quickly clicking the same animation is adding another blend to the stack. So if you click the button four times in quick succession, there could be more than two animations blending at once because you keep adding another blend to the stack. With each of these blends, you are also adding in the face morph animation. So you get an additional added face animation (wherever the face animation happens to be at the time) for each of the body animation clips trying to blend.

If you want to be able to add your face animations to the body animations and not run into this, you will need to make sure your blend speed on your clips is not slower than the rate in which you want your user to be able to click the UI button. A simple solve here would be to add a timeout on your button click to disable calling your blendAnimation function faster than your clips can blend. Or you could disable the button during that timeout so that the user can see that the button can’t be clicked quickly.

I hope this makes sense as it’s just a confluence of features you are using that all need time to resolve before they try to go to the next state. If you have more questions, feel free to ping back.

2 Likes

Thank you PatrickRyan. It was exactly what I was thinking it was happening, I just needed to be sure that it was not something else. I created blend function that actually deal with quick clicking between animations. What i need is to restart animation on each click, so that if i click wave quickly it will start from beginning, i want it to act the same as like when i enable blending. No mater what i do (reset(), goToFrame(0), stop()…) it breaks.
Here is playground with new blending function:

1 Like

The other thing you could do is have all of your animations in the play state and rely on the weights to blend between them. However, you do give up control of where the animations are in the timeline as they continue to play in the background. However, if you don’t have a lot of precision about needing to start at the beginning of the clip, you could make use of this.

Just set every clip to play and set all weights to 0 except for one. Then on click, rather than starting and stopping the clips, you will instead play animations that drive the weight values of the affected clips to 1.0 or 0.0. This means you won’t ever have duplicate iterations of the same clip playing and you will always have a smooth animation blend. You will likely have some overhead in clips playing with a weight of 0 so if you have a lot of animations on a character, you may not want to do this. But if you can group your animations to play only the possible states at once and blend between them, you will avoid some of this.

2 Likes

PatrickRyan Thank you for your help.

1 Like