Search Unity

Animation driven character motion, why does Mecanim loop me back to start?

Discussion in 'Editor & General Support' started by badotter, Mar 29, 2013.

  1. badotter

    badotter

    Joined:
    Mar 29, 2013
    Posts:
    19
    My apologies, this must have been asked a hundred times, but I'm still not finding a clear answer. I understand that Mecanim is supposed to be all about driving the character's motion by means of the animation's root transform, and I'm tantalizingly close to getting it to work, but it is not consistent.

    I am using Mixamo's Swat character, with their SwatAvatar, and importing anims that have root transform data as Humanoid type. However, no matter what combination of Root Transform or Root Motion options I select, the anims always play out and then return the character back to his starting position, where what I want is to play a cycle of the anim and then leave him where he ended the animation.

    The tantalizing part is I have made a trivial little state engine where the character changes from idle to walk to run states, and it actually plays the walk and then the run following each other without the run starting back at the place the walk started - it actually does what I want for this one transition. However any animation following the run starts all the way back at the place the character originally started walking. Furthermore, trying to repeat the walk multiple times also fails to keep the character moving forward, and no other combination of other animations results in moving the character forward, even though the settings are the same on all of them.

    Am I missing some obvious component here?

    Thanks for any assistance.
     
  2. JeppeNygaard

    JeppeNygaard

    Joined:
    Dec 7, 2010
    Posts:
    13
    I've been struggling with this as well and it took me a while to figure it out. There are a few important factors but one thing that really helped me was upgrading to unity 4.1.2 - up till this point Unity was VERY picky about how I exported my animation (Which version of maya and which version of the FBX exporter - I got the best result with Maya2012 and FBX 2012.2) ... Anyway, after upgrading to Unity 4.1.2 everything runs a lot smoother.

    And, yes you are right. Unity handles animation with root motion really well and it seems to be part of the main idea behind mecanim. And you're also right in assuming that the key to get this working is to avoid that the animations "resets" back to the beginning after every loop. So, after updating your Unity, make sure that the translation of your character (the root motion) is actually on the root joint of the character and somewhere further down the hierarchy. Next, when importing the animation into unity, make sure to identify this root joint in the inspector, set the range of your animation, check the "loop" checkbox and you should be all set.

    I hope this was helpful!
     
  3. ssedlmayr

    ssedlmayr

    Joined:
    Feb 28, 2013
    Posts:
    36
    @JeppeNygaard I am still having this issue in Unity 5.2, and your suggestions do not fix the issue. In fact, I've tried pretty much everything possible to try, including handling root motion myself via script with all root motion turned off, and it still doesn't work.