Search Unity

Handle transition in transition?

Discussion in 'Animation' started by dengzijian06, Jan 13, 2014.

  1. dengzijian06

    dengzijian06

    Joined:
    Jan 13, 2014
    Posts:
    5
    Hi,

    Some times I need to cancel current transition and turn to another transition. For example, I have IDLE RUN states, and transition condition like CMD2IDLE CMD2RUN. Start from RUN state, if I issue CMD2IDLE then CMD2RUN in succession, I expect the state end up with RUN, but now I got IDLE. It seems that mecanim can't handle CMD2Run when in 'RUN-->IDLE' transition.

    What can I do in that situation? THANKs!
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    This is what the "Atomic" flag on a transition is for. According to the documentation if a non-atomic transition is incomplete and the conditions for a higher-ranked (ie: higher in the list) transition are met then it will switch to that transition instead.
     
  3. dengzijian06

    dengzijian06

    Joined:
    Jan 13, 2014
    Posts:
    5
    Thanky you angrypenguin!
    But I thank there are delicate differences, that I am not mean Run-->Idle trans to Run-->Idle2. What I need is fastly end current transition Run-->Idle, so that I can perform Idle-->Run again, since there is no transition from Run-->Run.
    Does atomic will work for me this way?
     
  4. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Not sure about that. I'm just getting into Mechanim myself at the moment, I've been working with it for only about a week.

    There is a method in the Animator API to transition to a state, maybe look into that? I haven't checked it out, but my initial thoughts are that it would go from whatever you're doing directly to the requested state.
     
  5. dengzijian06

    dengzijian06

    Joined:
    Jan 13, 2014
    Posts:
    5
    OK,thank you, I will check the API!
     
  6. dengzijian06

    dengzijian06

    Joined:
    Jan 13, 2014
    Posts:
    5
    It seems CrossFade can't help me also since I don't know which tgt state currently it is. Is there any other solution, may be a transition queue will help, how to achieve that?