Search Unity

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

Animation transitions: Difference in effective length between states is too big. Transition preview

Discussion in '5.6 Beta' started by plmx, Feb 21, 2017.

  1. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    I've got an Animator which I can open and use fine in Unity 5.5. However, in Unity 5.6.0b9 (possibly earlier), when I select all but one of the transitions, I get the following error and, obviously, no transition view.

    Code (csharp):
    1.  
    2. Difference in effective length between states is too big.
    3. Transition preview will be disabled
    4.  
    I'm not sure sure what "effective length" this error message is referring to, but the length of the clips is between zero and about ~.5 seconds.

    I've also created a case, ID is 883536, where I've attached a small demo project.
     
    marequest likes this.
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    This error happens when the transition preview has to generate too many samples in order to preview the transition correctly. It just stops instead of looping forever and slowing down the editor.

    This usually happens when the speeds on the states are very low (leading to a very long effective state length), or you're trying to preview a transition from a very long idle Animation to a very short animation.

    As far as I remember, this code hasn't changed in 5.6, so maybe one of your clips got imported wrong, causing this issue.

    We'll have more info when we investigate the bug more in depth.

    Thank you very much for the bug report and for trying out the beta
     
  3. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    Hi @DavidGeoffroy,

    thanks for looking into this.

    I looked at the transitions again. It seems that the error is thrown when both clips are in fact of zero length. This error also occurred in 5.5, so that part is not related to 5.6.0b9.

    However, some of the clips that report a time of "0.333" in Unity 5.5 now report "0.000" after importing them into the beta (which happened some time in the past). So you are right, it is/was an import problem (can't reproduce it now - fixed already?).

    Anyway, shouldn't it be OK to have transitions between two zero-length clips too? In our case, we are essentially blending poses, so it would actually be most logical to have zero-length clips (i.e. one frame).

    -plmx
     
    Last edited: Feb 22, 2017
  4. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    If you have empty (or zero-length) clips, there's very little point in showing the transition preview, because there's no data to sample, and the empty state can't be shown (because it will have to be effectively zero pixels wide to be accurate).

    Moreover, all normalized values for the transition kinda break down on a length of zero.

    In normal conditions, you should never have a zero-length clip. Poses should have 1 frame of data minimum (so technically a length of 1/framerate).
     
  5. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    OK, so my issue here doesn't have anything to do with the beta, but rather "zero-length" clips.

    Here's my use case:
    • We have a hand which has several "poses", i.e. can grab various different things.
    • Each pose is a certain skeletal position - but only one, and thus only one keyframe. No animation. There is also one "idle" pose - also with only one position/pose/keyframe. The length of each clip is thus zero (one keyframe at 0:00).
    • We use a state machine to switch between the poses, thus creating animations, and Mecanim nicely animates the transitions between the poses.
    This works very well in Unity, and so far I assumed it was perfectly fine. In particular, I think it doesn't make sense for each pose to have more than one key frame, or to have any length at all. Thus, we have placed the key frame at frame 0:00 (because why place it at any other frame, or have two?), and then we have a fixed transition duration of 0.1. However, I get the warning we talked about, and no preview of the transition, on selecting a transition.

    However: If I change the fixed transition duration to 0.5 or greater - keeping the clips the way they are, i.e. at zero length - the transition preview we talked about shows up and looks OK. That this is showing the way it is makes sense to me, since the duration of the transition implies length for the entire transition animation (it doesn't make sense that it doesn't show for <0.5s).

    Now you said I shouldn't have zero-length clips. A clip with a single keyframe at 0:00 is reported as having zero length by Unity (in the inspector). Although I wouldn't call it "empty" I can understand the logic of it having zero length. But given my scenario above, what should I do instead?

    I can move the single keyframe to 0.01 - then the length is no longer zero. Or I can add two keyframes with the same information. However, both seems counterintuitive because now the clip has a length although it really hasn't - there is still only one pose in there, and it seems like a workaround.

    ---?
     
    Last edited: Feb 22, 2017
  6. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    I'll need to review the bug report in detail to figure out exactly what is going on.

    But I can safely affirm that (actual) zero-length is a problem when evaluating animations. We need to divide by length all over the code, and dividing by zero is bad news.

    We should have some checks in the import pipeline to ensure that clips never have a length of zero (I need to verify this), and these checks may have failed, but in any case, if you want to avoid issues, making your animations 1 frame long ( 0..1, 100..101) should help. Having a single keyframe there should be fine too.

    Whether your animation is 100 frames long or 1 frame long shouldn't change the size of the clip, it's the number of keyframes that determines the size, so there's no real drawback to making them 1 frame long.
     
  7. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    Thanks @DavidGeoffroy, appreciate the feedback! If a one-keyframe-clip (regardless of where the frame is) would be treated as a non-zero-length-clip (i.e. with a length of one frame) this would both solve the issue and be (to my mind) more logical.
     
  8. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    The issue was not with the length of the clip, but with transitions with an exit time of zero not being evaluated properly in this specific case.
     
  9. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    OK, thanks! Will keep an eye out in the next betas.
     
  10. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    Warning is still showing in 5.6.0f1.

    As you said, the warning shows if the exit time is zero, even if it is disabled. I.e., the warning does show for this transition (and there is no transition preview):

    ani-notok.png

    But it does NOT show for the exact same transition if the exit time is NON-ZERO, even if exit time is disabled. And, also, the timeline preview is shown in this case.

    ani-ok.png
     
    Last edited: Mar 27, 2017
  11. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    The bug is indeed an issue with transitions on exit time 0, and has nothing to do with the length of the animation, despite the error message.

    This fix won't be in the release for 5.6.0
    While a release is in Release Candidate mode, only major regressions introduced in the version and crashes get their fixes merged, to avoid introducing new regressions along with a minor bugfix while we're stabilizing the version.

    Since this bug has been there since at least 5.5, it doesn't warrant the risk for 5.6.0.
    I've opened a request for the fix to be included in a 5.6 patch release.
     
    plmx likes this.
  12. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    ok, thx for the info!