Search Unity

Bug Additive Reference Pose to clip cannot be used in builds

Discussion in 'Animation' started by TimHeijden2, Jun 3, 2021.

  1. TimHeijden2

    TimHeijden2

    Joined:
    Aug 11, 2016
    Posts:
    86
    I have a scenario in which I'm using an animator with a lot of additive animations. In the editor, it is already possible to define a reference pose animation frame inside a specific animation:
    upload_2021-6-3_10-30-20.png

    This creates an overhead though, because the animator would need to add a T-pose to all of the additive animations and then spend time configuring this animation in unity to not play in the actual animation itself. This becomes more problematic when using looping additive animations, where adding the reference T-pose breaks the curves and thus forces us to disable compression / resample curves.

    A proposed solution by @Mecanim-Dev is to use the AnimationUtility:
    https://forum.unity.com/threads/animator-avatar-mask.423841/#post-2744532

    Which would look something like this:
    Code (CSharp):
    1.  
    2. foreach (AnimationClip clip in clipsToUpdate)
    3. {
    4.     // Option A
    5.     AnimationUtility.SetAdditiveReferencePose(clip, referenceClip, time);
    6.  
    7.     // Option B
    8.     AnimationClipSettings settings = AnimationUtility.GetAnimationClipSettings(clip);
    9.     settings.hasAdditiveReferencePose = true;
    10.     settings.additiveReferencePoseTime = time;
    11.     settings.additiveReferencePoseClip = referenceClip;
    12.     AnimationUtility.SetAnimationClipSettings(clip, settings);
    13. }
    14.  
    This solution has a few problems however:
    1. It only works using editor code, so you can't apply a reference pose at runtime
    2. This value is NOT serialized, meaning that it only applies for your local machine, and when you restart unity or reimport the file, you would need to apply it again. When making a build, you'd also need to reapply it.
    3. It doesn't actually work when you make a build in -batchmode

    I had already written code to constantly re-apply it to make it work in editor & normal builds, but it not working -batchmode either basically means that it is unusable and no longer a viable solution for us.

    This "bug" might borderline on a feature request, but it seems like a very important & basic thing to want to do. I can't imagine anyone that seriously uses additive animations wouldn't want to have a reference clip instead of needing to do a whole bunch of extra work.
     
  2. TimHeijden2

    TimHeijden2

    Joined:
    Aug 11, 2016
    Posts:
    86
    Last edited: Jul 8, 2021