Search Unity

Animator transition edits will not persist

Discussion in 'Animation' started by DannyCheng, Jan 28, 2015.

  1. DannyCheng

    DannyCheng

    Joined:
    Feb 25, 2013
    Posts:
    30
    Hello!

    I am trying to set up a sprite animation transition using mecanim and I am running into a strange problem.

    My transition is a trigger transition and the sprite performs a loop in the "from" animation (sweeping the floor with a broom) and a normal (non-looping) animation in the "to" animation (putting the broom aside)

    The "to" animation is set up to blend perfectly with the "from" animation (so its first frame follows on smoothly from the last frame of the "from" animation)

    However in the game when the transition triggers the blend looks wrong.

    Indeed inspecting the transition graph in mecanim reveals that for some reason the blend starts around the middle of the "from" animation instead of right at the end which is the intended behaviour

    "That's fine", I think, "I'll manually edit the transition through the graph so that the *whole* "from" animation plays first before we switch to the "to" animation, and also I'll completely remove the "cross fade" between the two clips.

    I do that and then preview the transition and indeed it looks perfect.

    However running the game again I get the same issue as before (transition looks broken)

    Inspecting the transition in Mecanim once again, reveals that the edits to the transition have been completely lost and for some reason the transition reverts to what it looked like before (with the blend happening around the middle of the animation instead of the end).


    So my question (or questions) is: Is this a bug? If so is there a known workaround? Is there a fix planned? Is it actually by design and I am failing to understand how I should properly use this feature? All I want is to be able to manually define the transition and for those changes to persist.

    Many thanks!
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    I don't know which version of unity you are using but if you don't have an ExitTime condition, mecanim is free to transition to your destination state as soon as the trigger is true. You can see that the icon change to show you that this transition have or doesn't have an exit time.

    In 5.0 we did change this a little bit because a lot of user were confused, we did add some text field for every editable parameter to allow fine grain value and added also a checkbox Has Exit time.


    transition.png
     
  3. DannyCheng

    DannyCheng

    Joined:
    Feb 25, 2013
    Posts:
    30
    Thanks for the response Mecanim.Dev.

    I am on latest release (sorry, should have mentioned) so 4.6

    Right, ok I kinda feared that might be what's happening...

    So you're saying if I use a trigger transition (which I kinda need to), there's no way I can specify that the animation clip must run its full course before the transition occurs? Basically mecanim will kick off the transition as soon as the SetTrigger() is called?

    If that's the case can you recommend any other ways that I could achieve the desired effect?

    It'd be great if there was like a "Transition Immediately?" checkbox for trigger conditions... It feels like something a lot of people could use...
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Since the blending look good only when you are at the end of your 'from' state, you should add ExitTime condition to make sure that the transition can only occur if the trigger is set to true and you are at the end of your 'from' state.
     
    DannyCheng likes this.
  5. DannyCheng

    DannyCheng

    Joined:
    Feb 25, 2013
    Posts:
    30
    Oh man I can't believe I am only *just* getting this!

    Ok so I thought adding additional conditions acted as an OR rather than an AND. So I thought if I had an Exit Time condition as well as the trigger, the transition would occur every time the clip reached its end.

    Of course that's not the case and doing what you suggested works perfectly fine (as multiple conditions need to all be true for the transition to occur - so an AND relationship basically)

    In hindsight it makes sense as if you wanted transitions to occur with an OR relationship you'd basically create completely different transitions rather than adding conditions to the same transition.

    Cool, thanks for helping me out with this Mecanim.Dev, really appreciate it!
     
    theANMATOR2b likes this.
  6. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Exactly, you nail it!
     
    DannyCheng likes this.