Search Unity

Play Mechanim Clip Immediately

Discussion in 'Animation' started by chilton, Sep 12, 2013.

  1. chilton

    chilton

    Joined:
    May 6, 2008
    Posts:
    564
    Hi,

    How do I tell Mechanim to play a particular clip immediately?

    As far as I can tell, if it's in the middle of one clip, it has to wait until that clip ends before it will read the state and decide on a new course of action.

    Thank you,
    -Chilton
     

    Attached Files:

  2. chilton

    chilton

    Joined:
    May 6, 2008
    Posts:
    564
    Right now I'm using a custom int variable that I change, and the animations start based on the value of that number. But this only works once the animation has completed. Is there a better way to do this?

    Thank you,
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    The animator should transition as soon as the conditions are true. If one of those conditions are "Exit time," then it won't transition until that time is reached.
     
  4. AdenFlorian

    AdenFlorian

    Joined:
    Feb 15, 2013
    Posts:
    7
    You can use multiple transitions from a state, I just learned. Create another exit transition from a state and then the transition line will have 3 arrows. on the first transition you can leave the exit time, and on the second one you can make a bool forceExit parameter that you can switch on for a frame and then it will transition out on command. Just make sure to turn it off the next frame. I haven't done this myself yet, but it's worth a try.