Search Unity

Accurate Animation

Discussion in 'Animation' started by Sygata, Oct 24, 2013.

  1. Sygata

    Sygata

    Joined:
    Nov 14, 2012
    Posts:
    17
    I am new to unity and am attempting to put together a runner game. I have been experimenting with Mecanim animations and to me it seems that they do not turn very accurately. From some Mecanim projects I have a plant and turn 90 degrees animation and a run animation. However, when I transition between them I can never get exactly a 90 degree turn.

    Do I need to tinker with my transitions to achieve 90 degrees? Or can that type of precision not be obtained?

    If it can't how can I go about designing a runner gamer with this inaccuracy using Mecanim; by not using root motion? Or is this something I should do using the legacy system.
     
    Last edited: Oct 24, 2013
  2. Sygata

    Sygata

    Joined:
    Nov 14, 2012
    Posts:
    17
    Here is a rar of my project.

    It contains a basic scene with blocks.
    My animator is called bob...
    There are two models in there both with prefabs for a simple drag and test for anyone to see.
    The default model the one for which the animations are made.
    The spikey model is from unity forums.
    https://www.dropbox.com/s/eprq6se1wi5a9ok/Yuriy Run.rar
     
  3. Sygata

    Sygata

    Joined:
    Nov 14, 2012
    Posts:
    17
    I have created a character control that handles the movement and mecanim handles the animation with root motion turned off.
     
  4. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    What do you mean by "root motion turned off. " exactly?
    Do you have your Root Transform Rotation property Based Upon set to original? I think you should so that Mecniam uses the orientation as defined in animation clip.

    Here's a doc on this: http://docs.unity3d.com/Documentation/Manual/RootMotion.html

    I am trying to figure all this out my self so please do share whatever you learn in the process of fixing this.
     
  5. Sygata

    Sygata

    Joined:
    Nov 14, 2012
    Posts:
    17
    On your animator which is attached to your character, you have a root motion check box. If this is checked then your mecanim controller will directly move your model without any code needed. Even with baking my root transform rotation into the animation I cannot get 100% accurate turns with this.

    So what I did is turn of the root motion and not bake anything into my animations. I then attached a character controller to my model and coded the actual movement. So my script controls the models movement through the scene, but mecanim controls what animation is played.

    The results are not quite as smooth as with root motion which is more accurate in terms of physics but I get 100% accurate motion.
     
  6. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    So your animations are in-place and you transform character around the scene with code?

    EDIT:
    oh ok so I see here: http://docs.unity3d.com/Documentation/Manual/ScriptingRootMotion.html that turning root motion off is exactly making animations to be in-place

    EDIT:

    But then mecanim will blend all this different animations of walking/running straight forward, left, right etc. How do you then know what velocity apply so that your caracter looks like walking and not sliding on ice. In other words how to synchronize current animation state that will be dynamic with Mecniam with your velocity so that your feat stay firm on the ground? Is there a Mecanim interface to assist you with that or do you have to do all the calculations yourself knowing more less what results Mecanim will produce when blending animations?
     
    Last edited: Oct 25, 2013
  7. Sygata

    Sygata

    Joined:
    Nov 14, 2012
    Posts:
    17
    Well currently for my runner game I don't need to account for that, everything simply worked. For a situation like that you could change the animator speed through your script and calculate the speed your character needs to travel. I can see this becoming quickly complicated.

    However, if your game is not a runner and does not need 100% accuracy, or you can control yourself real time, you could just rely on Mecanim; I could get my turns within 5 degrees with Mecanim. What you would have to do is have a boolean parameter if you you are on ice which you can set in your script. When this parameter is true you play your walk on ice animation.

    EDIT: The only reason I am not using Mecanim for motion is because I want exactly 90 degree turns. I only have 5 animations, run, turn left, turn right, dive, slide. I think if I was creating a 3rd person game I would rely on Mecanim.
     
    Last edited: Oct 25, 2013
unityunity