Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Animation null in states causing A-Pose, only in Built game not editor.

Discussion in 'Animation' started by ValkyrieAnim8, Nov 2, 2023.

  1. ValkyrieAnim8

    ValkyrieAnim8

    Joined:
    Aug 7, 2023
    Posts:
    7
    I have an animator with a couple hundred animations in it. In editor it runs perfectly fine. In game, there are 5 states that consistently T-Pose when I try to play them and on digging the clip in the state is null at runtime. I can not figure out what is different about these 5 animations. So far:
    1. moved all clips into resources folder - did not fix anything
    2. added try/catch to to the Animator.CrossFade() calls - did not fix anything
    3. I created a dictionary with all clips in the Awake() method and check each for null, this says that 5 are null (but because they are null I can't get their names).
    4. Created a new method for PlayAnimation which can check to see if the clip is in my dictionary and if not I can print out the state it is about to play in a runtime GUI and then play another animation to avoid T-posing - which writes its name in a runtime HUD. Doesn't solve the issue though.
    5. I have managed to find 2 of the 5 so far and re-import the animations, which fixed them.
    My issue is the 3 remaining clips that are null have to end up playing rarely so in the last few hours of my day I have been unable to figure out which ones they are.

    I have to figure out why these particular clips (or states) don't properly build even when they are in a resources folder and work perfectly fine in play mode in editor (my Awake() script finds no null clips in editor as well).
     
  2. ValkyrieAnim8

    ValkyrieAnim8

    Joined:
    Aug 7, 2023
    Posts:
    7
    _ RESOLVED _ : There is a clip type called a "PreviewClip" which has no way to know it is one in the editor (the only way we figured this out was diffing the .anim). The batch import animation pipeline we had to build to deal with Unity's terrible animation event system has to maintain 2 import files, the original still attached to the FBX importer animation and a duplicate in another folder which is tagged with events and used in game (which is apparently what most people do). This is transparent to the animation team however it allows animators to actually clean and iterate on animations without setting events all over again. The issue being, that if you copy the clip (which again, in engine says it is an AnimationClip) using an editor script it will create a previewClip (this has to be a bug because the editor seems to have absolutely no idea, no warnings, no build errors, etc...). Then it will allow you to use those preview clips in animator states that are actually used. They run perfectly in engine, and then don't build (again with no errors or warnings) and they T-Pose. There is no way to convert these clips according to everything we have found. We needed to make empty clips, copy the curves over which made our pipeline literally take 10x longer to import animation. But they don't T-Pose anymore.

    We did test just replace the 2 lines in the YAML that define it as a preview clip and replace it with the lines AnimationClip has, and - that actually did work, they built, however, having a text edit step on an animation import/update pipeline seems a bit risky.
     
    Last edited: Nov 6, 2023