Search Unity

Problems with the Mecanim Animation

Discussion in 'Editor & General Support' started by Leosubaru, Feb 5, 2013.

  1. Leosubaru

    Leosubaru

    Joined:
    Feb 5, 2013
    Posts:
    3
    Hello everybody,
    I'm a beginner in Untiy 3D and I'm trying to understand the Mecanim of
    Unity 3D. (and to solve my problems :D )

    First I have downloaded the testlevel with the Robot and watched several very nice videos like:
    https://www.youtube.com/watch?v=Xx21y9eJq1U

    I tried to use my own Character but I have serveral problems. (I use the
    Controller and Scripts of the testlevel.)

    1.
    Two Errormessages:

    Code (csharp):
    1. NullReferenceException
    2. ThirdPersonCamera.Start () (at Assets/Scripts/ThirdPersonCamera.cs:13)
    3.  
    4. NullReferenceException
    5. UnityEngine.Transform.get_position () (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineTransform.cs:19)
    6. ThirdPersonCamera.FixedUpdate () (at Assets/Scripts/ThirdPersonCamera.cs:31)
    2. The Animation of my Character works but the Camera is not working and the Player nearly doesn't move.



    Here are my Settings:
    http://s1.directupload.net/file/d/3157/v9aksc7u_jpg.htm

    I tried to solve my problems for hours but i don't find a solution.
    Hope you can help me.
    best regards
    Leosubaru

    EDIT:
    Here a short video of my problem:
    http://www.youtube.com/watch?v=159PjGXTP2c&feature=youtu.be
     
    Last edited: Feb 5, 2013
  2. Leosubaru

    Leosubaru

    Joined:
    Feb 5, 2013
    Posts:
    3
    Ok, the problem with the Camera we found out - but we don't find a solution why he doesn't/nearly moves.
     
  3. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,209
    I had some issues with my character not moving when I scaled it within the scene view. As soon as I brought it in at the default size, it worked fine. I also had issues when I scaled my model within the inspector, after selecting my model in the Projects tab and modifying the Scale Factor. My solutions was to re-size my character within my modeling/animation program to the correct size, and then exporting it to FBX. I hope that helps!
     
  4. Leosubaru

    Leosubaru

    Joined:
    Feb 5, 2013
    Posts:
    3
    Thank you very much :) That solves my problem :)
     
  5. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,209
    Why it does that? Who knows... I tried to get some solutions here from everyone with little avail. Anyways I'm glad it worked out for you!
     
  6. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    This behavior is normal. When you scale the model in the scene view, the root motion of the animation does not scale with it, but it remains the same. Let's say your character moves 10 centimetres (in the world) per second. Even if you scale the model 100x times bigger in scene view, the animation will still move it at 10 centimetres per second in the world. So if you make your model too big it will move extremely slow and if you make it super small it will move extremely fast. Hence the more you scale up your character the slower he will move, since 10 centimetres will become really small in relation to the big size of your character. If you want to test it try making it extremely tiny in the scene view and you will see how fast he will move.

    Bottom line: Do not scale the model in scene view, keep it at scale 1 always.

    -Now, you can always scale the model in Unity (in the fbx importer importer http://docs.unity3d.com/Documentation/Components/class-FBXImporter.html, look at scale factor)

    Then it will work, however all the animations used (like those from this tutorial that come from other models) have to be rescaled to the same FBX import scale, that is very important or Retargeting will not work. Its kind of sad because if you have a model at a certain size and plan on reusing animations on another model that has a different fbx import scale inside Unity, then you will need to duplicate those animation files and use the right import size on the right models.

    Now, there is an import scale/Mecanim bug however (I made a thread for this so that devs can see more easily : http://forum.unity3d.com/threads/169353-Mecanim-Avatar-FBX-Scale-bug) so thats why you might have had a hard time trying to scale the model with scale factor in Unity.

    If you change the fbx import scale on animations or models that had an avatar previously set/configured, it will mess up completely the model.

    So lets say your character is fbx scale 0.01 in the fbx importer. He has an avatar set and configured everything is great and you have an animation from another file that you use on this character (that animation is also fbx scale 0.01 in the importer). Everything is great, but then you decide you want to change their scales to 0.04 using Unity FBX importer because you want the character bigger.

    You make your character bigger by setting the fbx import factor scale at 0.04 and then your model will be messed up/streched or even collapsed and just really wrong. You can see it by pressing the configure button in the avatar definition in the Rigs tab. Another way to see it is to press play, you will then see the character completely messed up.

    To fix this you need to go to the Rig Tab and then set the avatar definition to "copy from other avatar" and then choose "none" and press apply. Then from the avatar definition now select "create from this model" and then press "configure" et voila! Your character should not be messed up anymore. You need to do the same for the animation if was using its own avatar. You need to repeat this process every time you change fbx import size.

    I suspect the bug is that mecanim doesn't update the fbx scale info in the avatar when you reimport a model using a different fbx scale. So mecanim would think its still scale factor 0.01 because that previous avatar was fbx scale 0.01 but it is actually 0.04. This is whats messes up the model but forcing it to "none" and then back to the original avatar forces it to update this information to 0.04 and fixes it.

    Anyways, I have done the tutorial using a size of 0.04 (using the fbx importer in Unity) with my own character and it does work.
     
    Last edited: Feb 7, 2013
    theANMATOR2b likes this.
  7. _Shockwave

    _Shockwave

    Joined:
    Sep 2, 2012
    Posts:
    21
    omg Alf203 you saved me! Your solution worked! Thank you so much from New Zealand ^_^.

    I had the exact same problem. I even posted a question on unity answers.

    Cheers buddy! you rock \m/

     
  8. Taziar

    Taziar

    Joined:
    Jun 20, 2013
    Posts:
    2
    Thanks, Alf. Was messing with this problem for an hour. I realized I needed to scale the model, but ended up with a blob instead of a character when I changed the scale factor. Thanks for the fix.
     
  9. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    976
    Ty, I've been re-scaling my character in blender earlier, but nice not having to do that anymore.
     
  10. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
  11. Croser

    Croser

    Joined:
    Mar 27, 2013
    Posts:
    1
    Somebody give this guy a medal!
     
  12. Infrid

    Infrid

    Joined:
    Jan 14, 2012
    Posts:
    67
    I love you. Seriously. I love you so much right now. God bless you.

    infrid.