Search Unity

Stepped Animation Keyframes

Discussion in 'Animation' started by Cactus_on_Fire, Jan 29, 2015.

  1. enblomquist

    enblomquist

    Joined:
    Jul 25, 2012
    Posts:
    85
    Has anyone been able to get this working using catrig? The step keys work for me using default bones and base objects exported from 3ds max. But, specifcally cat rigs curves are still being resampled.

    Thank you in advance!
     
  2. AKQJ10

    AKQJ10

    Joined:
    Feb 9, 2012
    Posts:
    33
    Hi, @DavidGeoffroy ,

    We are exporting animation FBX files from Max, Maya to unity. The rotation curve has only two key frames in Max, Maya. But Unity automatically adds interpolated key frames in every time step. The Unity animation importer settings are ResampleCurves: off; Anim.Compression: off;
    We have tried enable Anim.Compression, which will reduce key frames, but still not giving the two original key frames that are defined in Max, Maya.
    We also tried different export settings in Maya, Quaternion Interpolating Mode:
    <1> Retain Quaternion Interpolation
    <2> Set As Euler Interpolation
    <3> Resample as Euler Interpolation
    All three options can't fix the issue.
    On the other hand, the position curves are correctly imported to Unity, showing the same key frames as in Max, Maya, without any added key frames.
    I spent quite some time searching online, and this thread seems to be the most relevant. You have mentioned "as long as you are not using unity-unsupported FBX features like pre- and post- rotations on your joints", how to set those in Maya or Max?
    I'd really appreciate it if you can provide some advice. Thanks in advance. :)
     
  3. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    I don't have much experience with either software (I know the FBX SDK, but not necessarily how it maps to Autodesk software), but I have asked our animators if they can help you.

    In the meantime, here is what I know:
    • In motion builder, these options are named pre and post rotation, and are configuration options on the bones themselves.
    • In Maya, I think they are named joint orient and rotation orient, but I don't know how to set them
    • In 3DS Max, I think these options are named pivot options, and I also don't know how to set them
    • Finally, I do know that 3DS Max cameras use custom joint parameters, which make their rotations impossible to import as-is in Unity, and these are always baked.
     
  4. yanghai

    yanghai

    Unity Technologies

    Joined:
    Mar 30, 2015
    Posts:
    13
    David is correct in what is mentioned above, but here’s a little more detail on the subject…

    First, in addition to pre & post rotations, there is one more thing to keep in mind when exporting/importing animation from Maya/Max, and that’s world axis. Maya & Max do not have the same world axis orientation as Unity and therefore need to be converted when imported. This means that the only way to be 100% sure that your animation does not get resampled on import is to have a non-animated root. Animating a single cube with no parent will result in resampled curves.

    As for the Maya/Max/MotionBuilder pre & post rotations options, here’s some screenshots of what they look like in Maya, Max & MotionBuilder…

    Maya:
    Maya_joints.png
    Max (make sure to reset pivots):
    Max_pivot.png
    MotionBuilder:
    MoBu_joints.png

    Hope this helps!
     
  5. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    This is great info -- how about from Blender?
     
  6. AKQJ10

    AKQJ10

    Joined:
    Feb 9, 2012
    Posts:
    33
    Thanks a lot, @DavidGeoffroy , @yanghai
    Our animator had just found another approach. In Maya, create a cube, and place the camera under the cube. Do all the translation, rotation, scale changes on the Cube. The only curve that changes on the camera is the field of view attribute. Export the .FBX file to unity, with ResampleCurves: off; Anim.Compression: off;
    All curves are showing the same key frames as in Maya, without any added key frames.
    upload_2019-4-28_17-52-28.png
     

    Attached Files:

  7. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    324
    You consistently post such brilliant ideas, I just wanted to say thanks from 5 yrs in the future :)

    We were struggling with how we could experiment with stepped-style anims, without a ton of re-authoring. I knew I could probably step through a single clip easily enough, but couldn't think how I could retain AnimatorController support w/ blending and layers. Your suggestion obviously checks all the boxes in it's pure elegance.

    For anyone interested, you can get a step style anim using this simple script:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEditor.Animations;
    4. using UnityEngine;
    5.  
    6. public class SteppedAnimator : MonoBehaviour
    7. {
    8.     [Range(1, 60)]
    9.     public int fps = 12;
    10.  
    11.     protected int _framesToSkip = 0;
    12.     protected Animator _animator;
    13.  
    14.     protected void Start() => _animator = GetComponent<Animator>();
    15.  
    16.     private void Update()
    17.     {
    18.         var skipCount = Mathf.RoundToInt(60f / fps) - 1;
    19.         _animator.speed = 1 + skipCount;
    20.         _animator.enabled = _framesToSkip == 0;
    21.         if (_animator.enabled)
    22.         {
    23.             _framesToSkip = skipCount;
    24.         }
    25.         else
    26.         {
    27.             _framesToSkip -= 1;
    28.         }
    29.     }
    30. }
    It just enables the Animator once every X frames, and also increases the speed by that same amount so that the overall animation plays at the same speed. Works like a charm, no curve adjusting needed :)
     
  8. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    That is brilliant.
     
  9. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    I haven't had time to test, but I wonder -- does this technique work with the new Animation Rigging workflow?
     
  10. PixelDough

    PixelDough

    Joined:
    Apr 27, 2018
    Posts:
    56
    I'm not sure about that technique, but if you're still looking for an answer I do know that I ran into the issue of simulating lower framerate animations (aka, stop motion) a few months ago. I came up with a script that you can put on any game object with an Animator Component, and it'll conform to the framerate you tell it to. It works with layers, blends, and everything Mechanim can do!

    Retro Framerate Controller by PixelDough (itch.io)

    I'm planning on putting it onto the Asset Store soon.
     
    awesomedata likes this.
  11. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Exporting stepped keys have been working great for us so far, but we hit a problem today. No matter what we do we cannot get our rig to export into stepped keys anymore (Unity 2019.4LTS, FBX2018). We manually bake the keys in Maya, and turn off resample curves and frame compression in Unity import settings.

    When I look at the tangents for my animation in Unity it looks like this:
    upload_2021-3-16_12-36-5.png

    It looks fine in Maya when i import the data from the FBX.
    upload_2021-3-16_12-38-36.png

    I dont have time to debug why this is happening, my first thought was it was related to pre-orientations since we have joint orientations in our rig. But creating a new rig with a couple bones with joint orientation exports and imports fine. Second guess was due to some constraint setting, but after a quick test that worked fine too. I will do some more debugging once I have time, and submit it as a bug if I figure out when this is happening.
     
  12. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    It seems it is actually importing some stepped tangents correctly, while others have the correct "tangents" when viewed in Animation Editor but the actual curves go crazy between the frames. I have a fbx with stepped keys that are working and some that are not working.

    *EDIT* I now reported it as a bug to Unity (Case 1322543), If anyone else stumbles upon this, here is what my stepped keys look like in the Animation Window in Unity. Some are fine, then suddenly others stepped keys have crazy curves.

    upload_2021-3-18_10-0-53.png
     
    Last edited: Mar 18, 2021
  13. grossimatte

    grossimatte

    Joined:
    Mar 15, 2013
    Posts:
    43
    I am still having this issue in 2021. Not sure how they have fixed this. Can someone highlight the solution to me as i don't seem to find it in this thread.

    Thanks a lot!
     
  14. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Which version of 2021 are you using? I got the following response from Unity
     
  15. yagiztunceli

    yagiztunceli

    Joined:
    Jul 17, 2022
    Posts:
    1
    Hello, i know this post is old I was dabbling with this today, the solution was weird to say the least, don't ask me why it works, here it goes.

    SOLUTION:

    1: Reference the object into the Maya scene, and animate your character.

    2: Bake the animation on the referenced rig.

    3: Import (not reference) a plain version of your FBX model that you animated.

    4: Copy the baked keyframes from the Referenced rig into the Imported rig.

    5: export the imported rig with the baked animations

    and voila it works!...... In my case.
    Hope this helps someone, no idea about blender
     
    Last edited: Feb 17, 2023
  16. ryanmillerca

    ryanmillerca

    Joined:
    Aug 12, 2012
    Posts:
    143
    Hey there, just chiming in (on this old thread) that Animated Custom Properties are having the issue many are describing here. I have keyframed stepped curves in Maya, and upon importing to Unity, I get splined curves with antic/overshoot. This is with Resample Curves off and Anim. Compression off.

    It's very important that Unity respects imported animation curves. Duplicating animation clips to edit them in post is not really an acceptable workaround.