Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mecanim Unity 4.0 starter tutorial

Discussion in 'Community Learning & Teaching' started by willgoldstone, Nov 24, 2012.

  1. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi all, so we've just got 4.0 out the door, so I made some time to remake my beta tutorial for Mecanim into a finished version for unity 4.0, please take a look -

    https://www.youtube.com/watch?v=Xx21y9eJq1U

    any feedback very welcome - and for those of you waiting on our new tutorial area, as part of the Learn section we're working on, we'll put out a blog post about our progress next week and i'd like to thank you for your patience in waiting for this resource.

    UPDATE!!

    We now have a Beginner Animation series of tutorials you should watch instead of the above, as they're much more up to date -

    http://unity3d.com/learn/tutorials/modules/beginner/animation

    Cheers

    Will
     
    John3D likes this.
  2. leonardoaraujo

    leonardoaraujo

    Joined:
    Jun 3, 2010
    Posts:
    87
    Nice tutorial! Question the mecanim system is only avaible on the pro version right? I have the pro 3 but did not upgrade yet
     
  3. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    That's incorrect, it's in free also. Some features are restricted to Pro, like much of Unity, but the basic functionality of Mecanim is in free. As usual, check our license comparison for details here -

    http://unity3d.com/unity/licenses
     
  4. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    Reposted? Anyways, this is a very nice overview of Mecanim.
     
  5. Nubz

    Nubz

    Joined:
    Sep 22, 2012
    Posts:
    553
    My patience wears thin Will
    LOL I am kidding I just am excited to see what you have done with the Learn section since everything I look at, read, or watch that you have done has been so easy to follow and understand

    Thanks for the new tutorial also
     
    Last edited: Nov 28, 2012
  6. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Will,

    Is the Tutorial scene in the Mecanim Example Scenes? I don't see it. Thanks.
     
  7. Rush-Rage-Games

    Rush-Rage-Games

    Joined:
    Sep 9, 2010
    Posts:
    1,997
    Awesome, thanks!
     
  8. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Good info, but I found that many animations don't have collider curves . I ended up writing my own code with hottween for re-sizing .
     
  9. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Yes reposted - I made a similar tutorial for Mecanim when it was in Beta, this is now removed from youtube etc, and this one replaces it with the 4.0 workflow / better presentation (I hope!).

    Cheers

    Will
     
  10. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Will, thanks. If you need any help with integral calculus let me know. You are pretty good teacher.
     
  11. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    Great tutorial!
    Edit: ah found a lot of stuff. Most things seem to work well.

    Apart from that great quality vid.
     
    Last edited: Nov 28, 2012
  12. unitydvr

    unitydvr

    Joined:
    Nov 27, 2012
    Posts:
    6
    [Link no longer valid and removed by moderator]

    prepare your self for live streaming at 2013 (next summer).

    it's full online intensive course in unity3d 4 and cinema 4d r14, and its for new (zero) developers .
     
    Last edited by a moderator: Jun 4, 2014
  13. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    If you downloaded the project from the Asset store clicking on the tutorial folder will bring up the Tutorial-start file in the Asset dialog. Edit: oops I think the files are here http://files.unity3d.com/will/MecanimTute.zip

    Went through the tute
    windows 7 64bit

    Would be great to see how we go from walk to run. I may have missed it but I couldn't see how to impliment that from the vid.

    Seemed like sometimes the video was cut when moving from function to function or calling scripts. These are things you have done a zillion times so its hard to spot.

    Combination of left alt and space bar for the wave animation during laser shooting brings up application window functions in windows 7. It's a native hotkey combination.

    You have a very pleasant voice which makes it easy to follow the lesson and concentrate over a long period.
    Thanks again.
     
    Last edited: Dec 2, 2012
  14. hike1

    hike1

    Joined:
    Sep 6, 2009
    Posts:
    401
    Why is the grabitem wrench oriented differently in my model though? This looks like
    the start of different weapon equipping, at least to a non-programmer.
     

    Attached Files:

  15. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    @hike1 you're presumably looking at the old tutorial which featured a wrench grab. It will be oriented differently in your 'dark mysterious dude' character because part of the process of picking up an object is orienting it to a transform attached to your hand bone in the character. Ensure the transform is in place, and rotated correctly if you're trying to do this.
     
  16. Anderson-Taborga

    Anderson-Taborga

    Joined:
    Nov 12, 2012
    Posts:
    2
    Very good explanation, however still do not understand the part of the inspector Gui when I put the pictures on the component to show the texture and does not appear to complete a pre-visualization. In Unity 3.5.6 this functionality is OK!

    I also wondered why so use to see objects in the directional vectors are not equal to unity before? there is a function that I can change this?
     
  17. hike1

    hike1

    Joined:
    Sep 6, 2009
    Posts:
    401
    Referring to the old 'grabitem' tutorial, at the 23:28 mark where the transition from Locomotion to Jump is shown, there are Jump conditions
    called 'if, if not, greater, less, exit time, equals, not equal', which I'm not seeing in my inspector. Also the Kylerobot Locomotion to
    Jump has 'Jump-true', which is because it's a boolean, And also Speed greater than 0.5. This is working with the Kyle robot, but
    no with my humanoid guy, I'm using a different jump animation, the transition plays in the preview window fine, any idea why
    not in the game?

    2. The check mark in animator window next to Jump, if checked means, 'play this no matter what'?, when checked, jump plays when
    I press the wkey.
     
  18. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Sorry Anderson I'm struggling here to understand what you mean by both queries? could you please rephrase?
     
  19. Kale

    Kale

    Joined:
    Aug 25, 2011
    Posts:
    103
    Question about the animations..... what's the difference between the animations before, and the animations used in Mecanim? And how would one go to make ones work for Mecanim. I never touched animations in my life, so... if this is somehow common knowledge.. I'd love to get in on that.
     
  20. Scobbo

    Scobbo

    Joined:
    Aug 18, 2012
    Posts:
    43
    Hi,
    I love your tutorials and books! Thanks for this one, it is very easy to follow. Couple of things though, I can't find the walk forward and turn animations in the list of assets. And I think you may need to add in something about setting the animations up from scratch. I imported them into my project and created a fellow (as a placeholder for more appropriate animations coming) and I went to crop the animation clips but the center of mass was not staying with the model and I could only see the character turning in one direction. After a while searching I found the mirror check box and that I had to not only set the models "type" to humanoid but also that of the animation. I might just be slow but I think that is something that should be covered.

    Can't wait to see what else you have for us Will.

    Kind regards.
     
  21. abhishek.shodhan

    abhishek.shodhan

    Joined:
    Dec 13, 2012
    Posts:
    4
    Hey Guys, I Check Tutorial in Unity 4.0 but I got problem when i import my own model.
    I Can't rig that model in unity and when I go to in rig panel and select humanoid, I show "not enough bones to create human avtar (requires 15)"
    please help me guys...
     
  22. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    Unity isnt a rigging program. You have to import a rigged and skinned character and then map the bones of your character to the mechanim system. In the tutorial you hear that the robot being used has 'no animation whatsoever' but he does have a skeleton. If you have the tutorial you can expand the robot hierarchy to see how it is set up. You need something similar for your character.
     
  23. shader

    shader

    Joined:
    Apr 4, 2009
    Posts:
    253
    Thank you Will for an excellent tutorial.

    Could someone produce a video or point me to one that shows how to rig a very simple character in 3ds Max that's suitable to use for use in Unity 4 ?
    I have some limited rigging experience with 3ds Max but i have nver exported anything.

    Also, could just the biped (without a skin) from 3ds Max be used (out of curiosity ) ?

    Thanks
     
  24. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    There are 3 systems you can use: Max bones, Character studio (CS) and Character Animation Tools (CAT).
    Tutorials for rigging and skinning a character with CS are in the user reference documents under the Max help menu. Animating with CS is there too. Rigging a simple character with CAT and also animating it with procedural CAT motion you can find on youtube: http://www.youtube.com/watch?v=hDoCKKGNOv8 Just dont watch the import into udk part :)

    I hear Unity loves CS. I have a cat rig in Unity and the integration looks darn seamless, The blending of various animations in the controller is pretty magic with this new system only I am having a hard time connecting them to the character as the BotControl script that comes with the tutorial isnt working for me so I cant vouch for it yet. I am still digging but one of the three choices is yours.

    If you decide to go with CAT then select the rig and the mesh and use export selected/ FBX/ 2013 (at the bottom). Open up the include section and check Convert Deforming Dummies to Bones (you can find that in the FBX export docs), Preserve edge orientation, Animation, Bake animation (frames show automatically) Deformation, Skins, CAT characters as HIK, Binary. Make sure animation is enabled on the rig to export animation and then hit the go go button :)

    Cheerio

    Edit

    First place I should have looked:
    http://docs.unity3d.com/Documentation/Manual/MecanimAnimationSystem.html

    Here it says the hip has to be the root in the hierarchy. I think with cat it is the platform the rig stands on so you might want to stick to CS unless someone has more info on this.
     
    Last edited: Dec 16, 2012
  25. shader

    shader

    Joined:
    Apr 4, 2009
    Posts:
    253
    Kanga

    Thank you for your help, this is great
     
  26. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    Just an update. I went through the mill and tried to get my not so standard humanoid working with max bones and motionbuilder but mobu dont want to play with my stuff :) Went back to check the cat rigged character and it all works. The nice part about cat is you can already have a walk motion in the pose you want which is great until we find out more about the muscle thing in mechanim.

    To get the cat rig WITH animation into unity the above still applies only make sure cat motion globals (if you are walking or running) are set to 'Walk On Line' under the cat motion parameters window and that the rig is in animation mode for export. Hide everything in your 3d app you don't need and select what you want to export, Export Selected' as fbx like above. You can drag drop the exported file of the cat rig and your skinned mesh into the assets window in unity and the file will be copied to the appropriate folder in your project. To get the your character up and running is the same as in the tute here except for a few things, so you have to map your rig first. When you add the controller from the component menu at the top it will come in at the centre of the platform. If you have done walk on line then the mesh will be at the end frame away from that centre of the cat rig parent depending on what order you do things in which is where it should be. You can add the IdleRunJump AnimatorController from the tute files to your character and the IdleRunJump script from the tutorial and it will all work! You have to loop the walk on line animation with the unity animation editor to get continuous motion. The nice part is you can open up the animator controller and click on the elements and substitute your own animations for what is already there.

    Hope this helps.
     
    Last edited: Dec 31, 2012
  27. EvansGreen

    EvansGreen

    Joined:
    Nov 9, 2012
    Posts:
    129
    Brilliant tutorial. It really allows you to get a quick grasp of mechanim... 100% recommended!

    PS: Thanks Will for your illustrative teaching resources, they're invaluable for most of us!
     
  28. Victor-Cardona

    Victor-Cardona

    Joined:
    Apr 6, 2011
    Posts:
    14
    Hello, Amazing and very useful tutorial, thank you so much.

    I am a 3D artist, Blender user, ive followed the tutorial and research a little more achieving this:




    Im using Blender 2.5, the rig was generated with Rigify and i put the .blend directly inside a folder in my project.

    Before importing my blender character using rigify rig i installed this plugin for unity

    https://www.assetstore.unity3d.com/#/search/rigify


    After that i converted my model to a mecanim avatar and added all scripts and components needed. and my character just works, it has problems but is my unfinished rig, im improving it.

    My question now is how do i extend the funcionality of BotControlScript.cs? i need weapons and enemies, but i dont know from where start because all the assets and characters systems are made for legacy and is hard for me try to port them.

    Please extend your mecanim tutorials and take a look at this couple of assets


    https://www.assetstore.unity3d.com/#/content/6216

    https://www.assetstore.unity3d.com/#/content/5969


    I want to make an online game using photon cloud and mecanim, for that im studying this example

    https://www.assetstore.unity3d.com/#/content/5824

    Very illustrative.
     
  29. Victor-Cardona

    Victor-Cardona

    Joined:
    Apr 6, 2011
    Posts:
    14
    Hello everyone, nice tutorial, ive followed it and this is the result



    Now i want to add more animations and weapons for this characters but i dont know how, recently i found this interesting article in Gamasutra:

    http://www.gamasutra.com/blogs/HeikkiTormala/20121214/183567/Creating_fluid_motion_transitions_with_Unity_and_M ecanim.php

    It explains lots of things lots of detail about mecanim and demonstrates what is possible to do with.

    Another excellent source of knowledge about mecanim could be found in the Vostopia Mecanim demo, it goes further and implements the amazing PUN Photon Unity Network AND Vostopia Avatar system, its based on Will Goldstone's mecanim tutorial but polished.

    Can be downloaded here:

    http://u3d.as/content/vostopia/vostopia-mecanim-demo/3NJ

    Even more information inside this package:

    https://www.assetstore.unity3d.com/#/content/5328

    Inside you can find mecanim scenes explaining how to make a very basic bazooka, mesh navigation, among other things

    If you need more animations the unity guys nicely gives us this package

    https://www.assetstore.unity3d.com/#/content/5330


    In this asset you can find a more detailed information about unity networking with mecanim, i guess photon is used, but i havent purchased it.

    https://www.assetstore.unity3d.com/#/content/6216

    I'm not so far yet with mecanim to having problems with events but seem what many people is having problem handling events with mecanim, it seems what the event system only is compatible with legacy animation system.

    Other people had founded some trick to hack this problem

    "One solution I've come up with to try and share some of my transitions is a hacked together "event" system. An event was fired on the code side by flipping a boolean property from 0 to 1 for one frame, and then back to 0 the next (done using a yield to keep it simple). These events were then safe to use in transitions from the "any state" node, since they'd only fire for one tick and not every single tick thereafter. I was able to keep a number of state machines almost entirely unconnected on a single layer, with discrete graphs for jumping, grounded animation, and clinging to ledges being managed by "EventGrounded", "EventJumping", "EventRelease", and "EventCling" properties.

    A proper event system would be awesome, but in lieu of that hacking one in hasn't caused me any issues yet. "

    Said by Ian Morrison at gamasutra article.

    There is another asset available for this issue:

    https://www.assetstore.unity3d.com/#/content/5969


    What i want and need to do is to convert this asset to mecanim

    https://www.assetstore.unity3d.com/#/search/cartoon%20soldier

    But i am not a programmer, i wrote to the author of this great cartoon soldier and he said "I may try to convert it myself, because the code is a bit outdated, but at least until February I'll be busy"

    Anyway it needs a complete rewrite to make it compatible with mecanim, im trying to convert it but i couldn't import the animations inside mecanim yet.



    And honestly i dont know where to start in the scripting part, i wish all this information be useful for everybody and if one of you can help me to port the cartoon solider to mecanim will be appreciated.
     
  30. Emericanized

    Emericanized

    Joined:
    Apr 30, 2010
    Posts:
    23
    Has anyone run into problems with using character studio bipeds with a prop bone and mecanim?

    Specifically:
    The prop bone is exported with animation, and the @animation file animates properly when dropped in the scene view.
    When applied to the mecanim character (same character, just the bind pose file setup with the control), the body animations play fine, but the prop bone maintains its default position and orientation. It just bobs up and down with its parent (the biped COM bone).
    I have "Keep additional Bones" selected for both the bind pose file and the animation.
     
  31. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    I havent done it yet (props) but wouldn't the bazooka sample scene have what you want?
     
  32. deltamish

    deltamish

    Joined:
    Nov 1, 2012
    Posts:
    58
    Hi Nice tut can i use this system(including blend trees
    ) for playing static animation not motion animation
     
  33. Emericanized

    Emericanized

    Joined:
    Apr 30, 2010
    Posts:
    23
    Hey, thanks for the reply! I think with their bazooka scene, they just have a hidden cylinder parented to the characters head, and they then use the mecanim hand IK system to stick the hands to it. That way everything is driven by the characters Head Look-at. Which works fine for something that you're only going hold against your head. In my case, though, the rig brings in a prop bone with it from Max -its animation baked in along with the characters- , onto which I parent the weapon.
     
    Last edited: Mar 28, 2013
  34. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    194
    @WillGoldStone Fantasic turotial, only one thing: I cannot import the extracted zip files into Unity. When I bring them to unity, all folders are empty... can you please help me.. obviously I am overlooking something ( I am new to Unity)
     
  35. Czar-Man

    Czar-Man

    Joined:
    May 10, 2013
    Posts:
    20
    Yeah the tutorial sure is nice. Unfortunately, I can't do a couple of things in the tutorial because I can't find any Curve options in the Animation settings. I read the faqs and it states that Curves are Pro-only.

    It would be nice if they actually told you that.
     
  36. Matthammer

    Matthammer

    Joined:
    Jun 3, 2013
    Posts:
    1
    Hi,
    Tutorial looks great. Looking to get back into animation etc.
    Although I've watched the tutorial having now come to the part of reproducing it, i seem to have hit an oddity which i have to assume is only me.
    I've got all the files into unity fine and can view the assets (scene, bot, dude etc) but one of the first things it says to do is go and check the muscle definitions and bone structure, but i have no options to do so. I realise the tutorial was done on a mac and i am on PC so i expect things to look slightly different and have also read that curve is pro only, but i've not seen other posts with this problem so as i say, i'm obviously doing something wrong.

    Whereas your inspector window shows 2 tabs 'model' 'animations' for idlegrab, mine shows 3 'model' 'rig' 'animations'
    Your Animations tab shows: Animation with ticked checkbox, Muscle Def - copy from other avatar, Source - dude avatar
    My animations tab shows: Import Animation with checked box, Bake animations greyed out, Anim. compression - keyframe reduction
    I found the Source - dude avatar, under the rig tab but none of the tabs show the muscle definition option.
    Naturally a pro version has more options, but generally as a result more tabs too, not less.

    I have the latest unity download from the site and the updated tutorial from earlier in this thread


    *Edit
    As the above muscle defs are just something to look at and non-essential i have skipped that and gone on to the part of actually working with the robot. I select the robot and go into the model tab on the inspector window and again, i am missing the important option. Whereas the tutorial shows a checkbox to 'create avatar' i do not have that option. There is no avatar section even. It simply goes straight from Material search option to the greyed out area of imported object. So unfortunately i am unable to do anything with it.

    Again as above i've not read anything about missing options beyond something to do with curves whch is pro only this must mean there is a bug for me alone. Any advice much appreciated.

    Regards
     
    Last edited: Jun 3, 2013
  37. indy2005

    indy2005

    Joined:
    Aug 22, 2009
    Posts:
    81
    Hi,

    Great tutorial. Spent an age trying to find out the curves option for the jump animation, only to realise it is a Pro only feature. As are light probes I think.

    Can I ask, you are using a capsule collider, could you not use the mesh of the animation to provide more realistic collisions? Also, how in such a system do you detect collisions with certain parts of the character such as a swinging sword blade etc.?

    Regards

    i
     
    sami1592 likes this.
  38. Gnaws

    Gnaws

    Joined:
    Jul 1, 2008
    Posts:
    43
    Agreed! These can't just be random biped FBXs, but must somehow be related to the Bot? Please address this Will.

    Otherwise, FAN-freakin-TASTIC tutorial!!!

    Thanks much!
     
  39. alterus

    alterus

    Joined:
    Sep 9, 2012
    Posts:
    59
    Will

    Your book is still the best Unity book around for beginners
    It would be great if you write an advanced 2nd editition focused on Scripting and Mecanim
     
  40. Ph0enix

    Ph0enix

    Joined:
    Dec 16, 2013
    Posts:
    13
    Hi Will,

    Thanks for amazing tutorials! Unfortunately I have a problem with this one..

    My Unity version is 4.3, it asked to upgrade project.

    After importing it gives me the following errors:

    SkinnedMeshRenderer requires a mesh with skinning or blendshape information. UnityEditor.AssetPreviewUpdater:CreatePreviewForAsset(Object, Object[], String)

    ImportFBX Warnings: Node 'Hips' has invalid Scale ChannelValues (0, 0, 0). Resetting it to (1, 1, 1). Node 'Spine' has invalid Scale ChannelValues (0, 0, 0). Resetting it to (1, 1, 1). ...

    Invalid GUIClip stack popping UnityEditor.DockArea:OnGUI()

    According to tutorial video at the same page When I click on Robot I should see Import Settings with a mesh but instead I just see a set of textures with no header or buttons whatsoever.

    How this can be fixed? I am looking forward to learning unity animation engine. Thanks for your help!
     
  41. tbhadzhi

    tbhadzhi

    Joined:
    Jul 27, 2014
    Posts:
    1
    Hello, can I just ask if the assets that come with the tutorials can be used for a student project as they are, particularly the scripts? I am building 2 characters and a level for the project. I've never touched coding before and mostly just do modelling but i was asked to put it in engine and I am having a hard time with the process.
     
  42. Hades II

    Hades II

    Joined:
    Oct 23, 2014
    Posts:
    55
    Hi i'm new new Unity and its community. This is great! But can you make an tutorial for importing Rage Pixel and using it. Also coding it in, that would be vary helpful. I've been trying to learn for two weeks now but i still haven't gotten anywhere.
     
  43. RPG buff

    RPG buff

    Joined:
    Jan 5, 2015
    Posts:
    3
    Im New Too Just Came From Playing Nintendo It Was Them That Recommended Unity
     
  44. sami1592

    sami1592

    Joined:
    Sep 18, 2013
    Posts:
    57
    same here, did not find the curves, was not sure if it is pro feature or not until this thread

    my ques is same as yours, what is wrong with using a mesh collider?

    second ques, how can i implement curve like behavior in the free version in a similar situation as the jump in the tutorial where i want the variable to change value with the animation.
     
  45. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Hi @willgoldstone -
    What's the difference between Mec in unity free and pro?
     
  46. pixelquaternion

    pixelquaternion

    Joined:
    Jun 28, 2014
    Posts:
    122
    Since unity 5 there is no difference you got all the features, enjoy and say thank to UDK for making it free so unity had to follow!
     
    CoCoNutti likes this.
  47. F18

    F18

    Joined:
    Mar 23, 2015
    Posts:
    18
    how import this file to unity if its was download. I have click import but this is only separate/ones?