{"id":1534,"date":"2012-12-30T16:59:06","date_gmt":"2012-12-30T13:59:06","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=1534"},"modified":"2012-12-30T16:59:54","modified_gmt":"2012-12-30T13:59:54","slug":"mecanim-unity-4-tutorial-step-by-step-from-the-video","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/12\/30\/mecanim-unity-4-tutorial-step-by-step-from-the-video\/","title":{"rendered":"Mecanim Unity 4 Tutorial (step-by-step from the video)"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1535\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/12\/30\/mecanim-unity-4-tutorial-step-by-step-from-the-video\/unity4_mecanim_tutorial_step_by_step\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/unity4_mecanim_tutorial_step_by_step.jpg?fit=680%2C394&amp;ssl=1\" data-orig-size=\"680,394\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"unity4_mecanim_tutorial_step_by_step\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/unity4_mecanim_tutorial_step_by_step.jpg?fit=680%2C394&amp;ssl=1\" class=\"alignnone size-full wp-image-1535\" alt=\"unity4_mecanim_tutorial_step_by_step\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/unity4_mecanim_tutorial_step_by_step.jpg?resize=680%2C394\" width=\"680\" height=\"394\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/unity4_mecanim_tutorial_step_by_step.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/unity4_mecanim_tutorial_step_by_step.jpg?resize=300%2C173&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>While looking at the new mecanim tutorial video, wrote down the steps from it (not finished yet)<br \/>\n(huh &#8211; thats a lot of clicks just to get your robot moving.. certainly could use some helper scripts\/plugins to do most of the stuff automagically)<\/p>\n<p><strong>Video from Unity (tutorial scene download is there also)<\/strong><br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=Xx21y9eJq1U\">https:\/\/www.youtube.com\/watch?v=Xx21y9eJq1U<\/a><\/p>\n<p><strong>Tutorial steps<\/strong><\/p>\n<ol>\n<li>Open Tutorial Start<\/li>\n<li>Pick Robot prefab<\/li>\n<li>Animations tab<\/li>\n<li>Uncheck [ ] Import animations<\/li>\n<li>Rig tab<\/li>\n<li>Animation type: Humanoid<\/li>\n<li>Apply<\/li>\n<li>Configure<\/li>\n<li>Configure Avatar<\/li>\n<li>Mapping : Automap<\/li>\n<li>(Some bones are red, because mecanim wants T-pose)<\/li>\n<li>Pose: Enforce T-Pose<\/li>\n<li>Muscles tab<\/li>\n<li>Prompts for Apply (apply)<\/li>\n<li>(We can apply constraints to different parts of the body, but no need to do now)<\/li>\n<li>Press Done<\/li>\n<li>Drag &amp; Drop the robot prefab to scene (hierarchy)<\/li>\n<li>(Scene uses light probes, need to set robot mesh renderer to use them)<\/li>\n<li>Select Robot in scene<\/li>\n<li>Select Robot2 under it<\/li>\n<li>Check [x] Use light probes in the skinned mesh renderer<\/li>\n<li>Select Animations\/Walk forward<\/li>\n<li>Go to animations tab<\/li>\n<li>Click clips\/Walk forward<\/li>\n<li>(You can then preview your animations (if they have baked mesh) or create loopable clips)<\/li>\n<li>Select robot in scene<\/li>\n<li>(it has component animator)<\/li>\n<li>Window \/ Animator<\/li>\n<li>Select tutorial folder<\/li>\n<li>Right click &gt; Create Animation Controller<\/li>\n<li>Name it MyBotControl<\/li>\n<li>Drag &amp; drop it to your robot, Animator \/ Controller<\/li>\n<li>Check [x] animate physics<\/li>\n<li>Go to animations folder<\/li>\n<li>Pick Idles<\/li>\n<li>Click Idle (under clips)<\/li>\n<li>See preview (press preview play button)<\/li>\n<li>Pick Animations\/Idles\/Idle (with play button icon)<\/li>\n<li>Drag &amp; drop it to Animator window (creates orange box *Orange is the default clip)<\/li>\n<li>Press Play to test the scene<\/li>\n<li>(Your robot now has the idle animation)<\/li>\n<li>Right click on Animator window, select Create state \/ From new blend tree<\/li>\n<li>Rename it as \u201cWalkBack\u201d<\/li>\n<li>Double click to enter it<\/li>\n<li>(From animator top left you can go back to parent, by clicking base layer, but not yet)<\/li>\n<li>Click + Button on inspector 3 times (for blend tree)<\/li>\n<li>Drag &amp; drop Animations \/ WalkBack \/ WalkBack clip to middle motion field that we just created<\/li>\n<li>Do the same for \u201cWalkBackTurnLeft\u201d (drop it to first motionfield)<\/li>\n<li>Do the same for \u201cWalkBackTurnRight\u201d (drop it to 2rd motionfield)<\/li>\n<li>** error : pressed some keys, whole animator went empty.. also couldn\u2019t go inside WalkBack anymore, had to re-do it.. **<\/li>\n<li>Add parameter: Speed\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (keep capital letter)<\/li>\n<li>Add parameter: Direction\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (keep capital letter)<\/li>\n<li>Select walkback blendtree<\/li>\n<li>On Inspector set Parameter dropdown to Direction (it was Speed)<\/li>\n<li>Set start range to: -1 (because unity input systems returns values from -1 to 1), by clicking the number 0 under the blue curves<\/li>\n<li>Go back to base layer (clicking the \u201cBase layer&gt;\u201d on topleft in animator window)<\/li>\n<li>Create transition from Idle to WalkBack, right click on Idle, Select Make transition, Drag the line to WalkBack, click.<\/li>\n<li>Click to select the transition line (we set condition that when should be do transition)<\/li>\n<li>Set conditions: Speed | Less | -0.1<\/li>\n<li>Create transition from WalkBack to Idle, right click on WalkBack, Select Make transition, Drag the line to Idle, click.<\/li>\n<li>Click to select the transition line (we set condition that when should be do transition)<\/li>\n<li>Set conditions: Speed | Greater | -0.1<\/li>\n<li>Go inside WalkBack blendtree, you can preview the direction value by dragging it on the blendtree<\/li>\n<li>Note. You can also drag &amp; drop any avatar enabled character to the preview window, to use it as a preview<\/li>\n<li>Select robot in scene<\/li>\n<li>Drag &amp; Drop \u201cBotControlScript\u201d to the robot<\/li>\n<li>Open the script (double click)<\/li>\n<li>Line 48: horizontal &amp; vertical get values from GetAxis()<\/li>\n<li>SetFloat() sends the values to animator<\/li>\n<li>(Back to unity)<\/li>\n<li>Set Robot rigidbody mass to: 60<\/li>\n<li>Freeze rigidbody rotation for all: XYZ<\/li>\n<li>Capsule collider: Set Center to Y:1, Height: 2, Radius: 0.3<\/li>\n<li>(Press play to test)<\/li>\n<li>** had some error here, robot is not moving as it should: Transition line from Idle to Walkback was not set \u201cCondition: Speed | Less | -0.1\u201d **<\/li>\n<li>(Video at 14:37 \u2013 Walk and Run : using Nested Blend Trees)<\/li>\n<li>Go to Animator, Base Layer<\/li>\n<li>Right click on stage: Create State \/ From new blend tree<\/li>\n<li>Rename it as \u201cLocomotion\u201d<\/li>\n<li>Enter the blend tree (double click)<\/li>\n<li>In inspector click + button: \u201cNew Blend Tree\u201d (And rename it as \u201cWalks\u201d)<\/li>\n<li>In inspector click + button: \u201cNew Blend Tree\u201d (And rename it as \u201cRuns\u201d)<\/li>\n<li>Select upper blend tree \u201cWalks\u201d<\/li>\n<li>Add 3 motion fields (+ button \u201cAdd Motion Field\u201d)<\/li>\n<li>Expand Animations \/ WalkForward motion clip in Project window<\/li>\n<li>Drag &amp; Drop \u201cWalkForward\u201d clip to the middle motion field<\/li>\n<li>Expand Animations \/ WalkForwardTurns motion clip in Project window<\/li>\n<li>Drag &amp; Drop \u201cWalkFwdTurnLeft\u201d-clip to top motion field<\/li>\n<li>Drag &amp; Drop \u201cWalkFwdTurnRight\u201d-clip to bottom motion field<\/li>\n<li>(you can pan the animator stage with middle mouse button down, or with alt+left mouse down)<\/li>\n<li>Select the blend tree \u201cRuns\u201d<\/li>\n<li>Set the range start to: -1 (like we did before @step 55)<\/li>\n<li>On Inspector set Parameter dropdown to Direction (it was Speed)<\/li>\n<li>Now select the lower blend tree (that we created @step 82)<\/li>\n<li>Add 3 motion fields (+ button \u201cAdd Motion Field\u201d)<\/li>\n<li>(Lets look how these clips were created)<\/li>\n<li>(if you select Runs (blue icon), and then select any of the clips listed, you can preview the loops)<\/li>\n<li>** Note: Some bug in the preview window: character disappears **<\/li>\n<li>(Lets remove Run clip, press minus under it)<\/li>\n<li>\u00a0(This fbx has several animations inside)<\/li>\n<li>(Add new clip, press plus)<\/li>\n<li>(select the just added clip)<\/li>\n<li>(Source take: Run, this will also rename your clip to Run)<\/li>\n<li>(if you press Play on preview window, you\u2019ll see its not perfectly looped)<\/li>\n<li>(You need to drag the Start &amp; End markers on the timeline to create loop)<\/li>\n<li>(Lets put start to 302 &amp; End to 319 \u2013 Drag end marker to 302, then keep dragging forward until the loop is complete \u2013 \u201cTraffic lights\u201d are also green then)<\/li>\n<li>(Check [x] the Loop pose)<\/li>\n<li>(Try playing preview)<\/li>\n<li>(Check [x] Bake into Pose under Root transform position (Y))<\/li>\n<li>(If you check preview you\u2019ll see that the guy is not running in straight line)<\/li>\n<li>(You can see in the text \u201cAverage velocity is -0.059, 0.000, 5.305\u201d, it should have \u201c0\u201d in X&amp;Y)<\/li>\n<li>(Under Root Transform Rotation drag the offset value, until your Average Velocity is correct \u2013 Set it to \u201c-0.64\u201d)<\/li>\n<li>(Click Apply at the bottom.. scroll the inspector if its not visible)<\/li>\n<li>(Check preview, not its running straight line)<\/li>\n<li>Expand Animations \/ Runs motion clip in Project window<\/li>\n<li>Drag &amp; Drop \u201cRunLeft\u201d-clip to top motion field<\/li>\n<li>Drag &amp; Drop \u201cRun\u201d-clip to top motion field<\/li>\n<li>Drag &amp; Drop \u201cRunRight\u201d-clip to top motion field<\/li>\n<li>Set the lower threshold start to: -1 (like we did before)<\/li>\n<li>On Inspector set Parameter dropdown to Direction (it was Speed)<\/li>\n<li>(we are now at 21:00 in the video)<br \/>\n..<em>to be continued<\/em>..<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>While looking at the new mecanim tutorial video, wrote down the steps from it (not finished yet) (huh &#8211; thats a lot of clicks just to get your robot moving.. certainly could use some helper scripts\/plugins to do most of the stuff automagically) Video from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1535,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[148,3],"tags":[304,386,383,307],"class_list":["post-1534","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-help","category-unity3d","tag-mecanim","tag-step-by-step","tag-tutorial","tag-unity4"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/unity4_mecanim_tutorial_step_by_step.jpg?fit=680%2C394&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-oK","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=1534"}],"version-history":[{"count":2,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1534\/revisions"}],"predecessor-version":[{"id":1537,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1534\/revisions\/1537"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/1535"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=1534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=1534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=1534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}