Finishing move animation humanoid issues

David Rico 9 years ago updated by tmpxyz 9 years ago 10
Hey Tmpxyz,

This is a followup based on the following question:

So I think I have it all mostly figured out. However I'm running into a bit of a problem.

If I use a Generic animator avatar, the process works fine and all is as expected in the documentation and example scene. The results are great.

However, most of my characters are Humanoid and I'm experiencing some issues due to that.

It appears that for the most part, the finishing move works as planned. However, with Humanoid animators the hands for some reason (and maybe a few other parts?) refuse to animate as per the .anim cutscene dictates. More specifically, the wrists, in my case. I did a series of tests and it appears the issue is directly linked to my model being humanoid, and the CC component using generic animations.

I know you have some documentation related to converting clips back and forth for humanoid/generic, but I don't believe there is anything regarding the CCEditor in particular, since it uses only .anim files rather than .dae as suggested for humanoid clips

Is this a known issue? Anything I can do to get around this? The CC system being generic only would really kill its usability for me and I suspect a lot of other people, since mecanim humanoid animation retargeting is necessary for my project.
Under review
Hi, David Rico,

Thanks for your feedback,

Alas, things would be much better if Unity had released the new Director system. =)

I don't quite get it, are you trying to use Humanoid animation clip under the CC's Animation component? How did you achieve that?

It's possible to drive a Humaniod rig model with Legacy animation clip.
I've just tested (Unity4.6.4) using a Humanoid-rig Robot model with CutsceneController, the animation clip is recorded under the CC's Animation component and is in Legacy format, it works fine when in game mode.

I think you might be using some special setup method? Could you elaborate more about how you're using the humanoid clip?

If possible, please send a minimum package to me by github / dropbox to test with.

Best regards, Be creative,
Hey Tmpxyz,

Thanks for the reply. I had some more time to investigate tonight, and I think I might know what the issue is.

It appears that the CC animation is not setting variables for some of the bones I didn't move/manipulate while recording the animation for the cutscene. Thus, I believe the problem is that the animations being applied to my characters prior to entering the cutscene might be blending into the CC animation.

So for example if my hands are closed in the Animator animation leading up to the CC animation, the hands will be closed while performing the animation even though if I look at the animation on the actual CC component, the hands might appear open (because the original model's pose defaults to open hands) while sampling the animation outside of gameplay.

Is there any way to essentially create a keyframe for every bone manually at once? This way I can create a start pose where I know every bone position/rotation will be set to some default pose at the start of the cutscene, and then any changes applied to it will look exactly as they do outside of play mode. I tried the Create Snapshot button but I believe that only creates keyframes for some of the bones, only the ones that have changes. I need something to snapshot all the bones, changed from default model pose or not :-)

Also is there any documentation for the Blend-in/Blend-out variables in the Cutscene component?
Hmm after some testing, I'm not sure if the approach I suggested will work. It still seems to be blending the Animator animations into it despite me manually setting the keyframes.

1. set key for many bones at once
Multi-select bones and click the "Set R key" will do.
It records the rotation keys for selected bones;

Shift-click to add/remove one bone from selection;
Ctrl-click to add/remove all descendants bones from selection;
If you ctrl-click the root bone( the sphere ), you will select/deselect the whole bone hierarchy.
Be noted: too much curves in animation window is not good for performance for UnityEditor;

2. Blend-in/-out time
If the time < 0 (default), the blend will not take effect.
So by default, there should be no blending.

Blend-in is executed after the CC animation starts; [means it blends with the CC animation]
Blend-out is executed after the CC animation stops; [means it blends with the normal animation]

3. The bone state
If the animation ONLY animates the neck, then other bones will stay how they were before the animation.

So according to what you described, the hand in question, you have made keyframes in CC clip to make the hand open, but you see it closed when play, right?

Please try these:
(1) make sure the dummy character under CC is stripped of the Animator/Animation component;
(the second button removes Animator/Animation components under CC)

(2) I remembered to have seen in some older version Unity that, a curve needs at least 2 keyframe to take effect, so if your curve has only one keyframe, it might have no effect.

If none of the above applies, please send me a simple scene showing this issue and I will find out what might go wrong with it.

Best regards, Be creative,

Figured it out!

So as it turns out, I was right about the animator/current character pose affecting the animation. In order to fix it, I basically added code that does the following before entering a "takedown" which is just a cutscene as per the examples you gave me.

1) Disable the animator for both characters (prior to starting cutscene)
2) For each model that will be in the cutscene, reset them to their default bind pose before starting
3) Proceed with the normal cutscene activation process as per the demos.

Here's the function I wrote that handles the reset so far, pretty sure I can clean up further, but it will help others perhaps.
private void DisableAnimator(Transform pawn)    {
        Animator anim = pawn.GetComponentInChildren<Animator>();
        if(anim != null)
            anim.enabled = false;

            //reset the bones to their bindpose
            SkinnedMeshRenderer skin = anim.GetComponentInChildren<SkinnedMeshRenderer>();
            if(skin != null)
                Transform[] bones = skin.bones;
                Matrix4x4[] invbinds = skin.sharedMesh.bindposes;

                //find root bone
                Transform pawnBoneRoot = RebirthUtil.FindChildTransformByName(pawn, bones[0].name);
                Transform[] pawnBoneTransforms = pawnBoneRoot.GetComponentsInChildren<Transform>();

                //add all bones to a dictionary
                Dictionary<string, Transform> pawnBoneDict = new Dictionary<string, Transform>();
                foreach(Transform b in pawnBoneTransforms)
                    pawnBoneDict[b.name] = b;

                foreach(Transform bone in bones)
                    Transform t = null;
                    pawnBoneDict.TryGetValue(bone.name, out t);
                    if(t != null)
                        ResetBoneToBindPose(t, invbinds, bones, pawn);

Hi, David Rico,

wow, it's great that you handled that =)

I'm still kinda confused, as I did disable the Animation/Animator components in CutsceneController.StartCC() => SwapGO() => _SetAnimatorEnableState()

private static void _SetAnimatorEnableState(GameObject go, bool state)    {
        Animation animation = go.animation;
        if (animation != null)
            animation.enabled = state;

        Animator animator = go.GetComponent<Animator>();
        if (animator != null)
            animator.enabled = state;
As I cannot reproduce this issue here, so for now I have trouble to figure out what could go wrong.

I really appreciate your effort.
I will keep an eye on this and make a fix when I find it,

Best regards,

Searching answer
Hey Tmpxyz,

Yeah I noticed the animator gets disabled during the CC, the main reason this worked for me is because the issue I was having was the last animation or pose the animator was in, was blending with my CC animation. So as such any bones which had not been animated in the CC, were "out of place" as compared to when I previewed my CC animation using the Unity Animation window.

With the code above, it forces the character into the bindpose before the CC starts, so it matches the start state of the CC animation and thus all bones/motion looks exactly as it does when I preview the cutscene in the Animation window.

Got it, I would suggest to just set the keyframes for the bones, but your method is great too.
Maybe I should add an option to snap back to bindpose when start too...

Best regards, Be creative,