Search Unity

Every animation is only 1 second in mecanim/animator?

Discussion in 'Animation' started by erana79, Apr 17, 2015.

  1. erana79

    erana79

    Joined:
    Jun 26, 2013
    Posts:
    61
    Hi everyone!

    I have an animation that's around 4.5 seconds long.
    When I use that animation with mecanim (Animator on GameObject, Controller, etc. all set up) the animation only plays for 1 second.

    The inspector shows the right duration, but when i play the animation in-game it's just 1 sec.

    Anybody else experiencing this problem?

    thanks!
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Animation can be of any length, there is no constraint on animation length.

    If you click on the animation and play the animation in the previewer does it still play only for 1 second and stop?
     
  3. erana79

    erana79

    Joined:
    Jun 26, 2013
    Posts:
    61
    Yes, the preview is 1 second as well.
    If i click the animation clip asset it says 4.5 in the "length"-label.

    If I open the animation's .anim file with a text editor, there is a tag m_stoptime which is set to 1. If i change that, the animation works.
    We recorded the animation via code from the gyroscope. Is there anything to keep in mind?
    We created an AnimationCurve, then used AddKey to add key frames, created an AnimationClip and set the curve via SetCurve. Finally we set a name and saved the AnimationClip with AssetDatabase.CreateAsset.
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Oh you did create all your clips by script.
    You need to fill up all the mecanim clip data too.

    Depending on which version you are using either you will need to use serialized object to setup your clip or use
    AnimationClipSettings AnimationUtility.GetAnimationClipSettings(AnimationClip clip)

    You are looking for those two properties.
    m_AnimationClipSettings.m_StartTime
    m_AnimationClipSettings.m_StopTime
     
  5. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    After some investigation there is a bug in 5.0, we are working on a fix.
     
  6. erana79

    erana79

    Joined:
    Jun 26, 2013
    Posts:
    61
    Alright! Thanks for the info!
    Please keep us posted!
     
  7. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    @erana79, can you log a bug with your project and some repro?
    We are working on a fix but we would like to test with your specific use case to be a sure that we fix the same bug.

    Send me your case number when you get it.
     
  8. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    The fix work for your case, the fix should be available in our next 5.1 beta 5.
     
  9. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    @Mecanim.Dev Is this the problem that I can't see more than one second in the inspector view (see screenshot). I'm using 5.1.1f1 and want to add events to my animation. You can see that the animations length is 2.875, but in the event area, I can only insert events to the first second.
     

    Attached Files:

  10. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    No it not the same.
    In this case the time line is in normalized time(%).
     
  11. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Ah, I see. Is this intended? I can't see an use case where this would be more useful instead of the real animation time. It's harder to calculate which percentage you have to use, but it's easy to select the frame where you want the event to be. Do I miss something here?

    In the animation window, I can also set up the events to the specific frame when the event should be triggered, so why not in the import settings in the inspector.
     
  12. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Yes it was intended but we do agree that this is not the best workflow to edit animation events.

    We did receive a few negative feedback about this so I will add a new item in our roadmap to investigate this to improve the workflow.

    Thanks for the feedback.