30
2012
Mecanim Unity 4 Tutorial (step-by-step from the video)
While looking at the new mecanim tutorial video, wrote down the steps from it (not finished yet)
(huh – 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 Unity (tutorial scene download is there also)
https://www.youtube.com/watch?v=Xx21y9eJq1U
Tutorial steps
- Open Tutorial Start
- Pick Robot prefab
- Animations tab
- Uncheck [ ] Import animations
- Rig tab
- Animation type: Humanoid
- Apply
- Configure
- Configure Avatar
- Mapping : Automap
- (Some bones are red, because mecanim wants T-pose)
- Pose: Enforce T-Pose
- Muscles tab
- Prompts for Apply (apply)
- (We can apply constraints to different parts of the body, but no need to do now)
- Press Done
- Drag & Drop the robot prefab to scene (hierarchy)
- (Scene uses light probes, need to set robot mesh renderer to use them)
- Select Robot in scene
- Select Robot2 under it
- Check [x] Use light probes in the skinned mesh renderer
- Select Animations/Walk forward
- Go to animations tab
- Click clips/Walk forward
- (You can then preview your animations (if they have baked mesh) or create loopable clips)
- Select robot in scene
- (it has component animator)
- Window / Animator
- Select tutorial folder
- Right click > Create Animation Controller
- Name it MyBotControl
- Drag & drop it to your robot, Animator / Controller
- Check [x] animate physics
- Go to animations folder
- Pick Idles
- Click Idle (under clips)
- See preview (press preview play button)
- Pick Animations/Idles/Idle (with play button icon)
- Drag & drop it to Animator window (creates orange box *Orange is the default clip)
- Press Play to test the scene
- (Your robot now has the idle animation)
- Right click on Animator window, select Create state / From new blend tree
- Rename it as “WalkBack”
- Double click to enter it
- (From animator top left you can go back to parent, by clicking base layer, but not yet)
- Click + Button on inspector 3 times (for blend tree)
- Drag & drop Animations / WalkBack / WalkBack clip to middle motion field that we just created
- Do the same for “WalkBackTurnLeft” (drop it to first motionfield)
- Do the same for “WalkBackTurnRight” (drop it to 2rd motionfield)
- ** error : pressed some keys, whole animator went empty.. also couldn’t go inside WalkBack anymore, had to re-do it.. **
- Add parameter: Speed (keep capital letter)
- Add parameter: Direction (keep capital letter)
- Select walkback blendtree
- On Inspector set Parameter dropdown to Direction (it was Speed)
- Set start range to: -1 (because unity input systems returns values from -1 to 1), by clicking the number 0 under the blue curves
- Go back to base layer (clicking the “Base layer>” on topleft in animator window)
- Create transition from Idle to WalkBack, right click on Idle, Select Make transition, Drag the line to WalkBack, click.
- Click to select the transition line (we set condition that when should be do transition)
- Set conditions: Speed | Less | -0.1
- Create transition from WalkBack to Idle, right click on WalkBack, Select Make transition, Drag the line to Idle, click.
- Click to select the transition line (we set condition that when should be do transition)
- Set conditions: Speed | Greater | -0.1
- Go inside WalkBack blendtree, you can preview the direction value by dragging it on the blendtree
- Note. You can also drag & drop any avatar enabled character to the preview window, to use it as a preview
- Select robot in scene
- Drag & Drop “BotControlScript” to the robot
- Open the script (double click)
- Line 48: horizontal & vertical get values from GetAxis()
- SetFloat() sends the values to animator
- (Back to unity)
- Set Robot rigidbody mass to: 60
- Freeze rigidbody rotation for all: XYZ
- Capsule collider: Set Center to Y:1, Height: 2, Radius: 0.3
- (Press play to test)
- ** had some error here, robot is not moving as it should: Transition line from Idle to Walkback was not set “Condition: Speed | Less | -0.1” **
- (Video at 14:37 – Walk and Run : using Nested Blend Trees)
- Go to Animator, Base Layer
- Right click on stage: Create State / From new blend tree
- Rename it as “Locomotion”
- Enter the blend tree (double click)
- In inspector click + button: “New Blend Tree” (And rename it as “Walks”)
- In inspector click + button: “New Blend Tree” (And rename it as “Runs”)
- Select upper blend tree “Walks”
- Add 3 motion fields (+ button “Add Motion Field”)
- Expand Animations / WalkForward motion clip in Project window
- Drag & Drop “WalkForward” clip to the middle motion field
- Expand Animations / WalkForwardTurns motion clip in Project window
- Drag & Drop “WalkFwdTurnLeft”-clip to top motion field
- Drag & Drop “WalkFwdTurnRight”-clip to bottom motion field
- (you can pan the animator stage with middle mouse button down, or with alt+left mouse down)
- Select the blend tree “Runs”
- Set the range start to: -1 (like we did before @step 55)
- On Inspector set Parameter dropdown to Direction (it was Speed)
- Now select the lower blend tree (that we created @step 82)
- Add 3 motion fields (+ button “Add Motion Field”)
- (Lets look how these clips were created)
- (if you select Runs (blue icon), and then select any of the clips listed, you can preview the loops)
- ** Note: Some bug in the preview window: character disappears **
- (Lets remove Run clip, press minus under it)
- (This fbx has several animations inside)
- (Add new clip, press plus)
- (select the just added clip)
- (Source take: Run, this will also rename your clip to Run)
- (if you press Play on preview window, you’ll see its not perfectly looped)
- (You need to drag the Start & End markers on the timeline to create loop)
- (Lets put start to 302 & End to 319 – Drag end marker to 302, then keep dragging forward until the loop is complete – “Traffic lights” are also green then)
- (Check [x] the Loop pose)
- (Try playing preview)
- (Check [x] Bake into Pose under Root transform position (Y))
- (If you check preview you’ll see that the guy is not running in straight line)
- (You can see in the text “Average velocity is -0.059, 0.000, 5.305”, it should have “0” in X&Y)
- (Under Root Transform Rotation drag the offset value, until your Average Velocity is correct – Set it to “-0.64”)
- (Click Apply at the bottom.. scroll the inspector if its not visible)
- (Check preview, not its running straight line)
- Expand Animations / Runs motion clip in Project window
- Drag & Drop “RunLeft”-clip to top motion field
- Drag & Drop “Run”-clip to top motion field
- Drag & Drop “RunRight”-clip to top motion field
- Set the lower threshold start to: -1 (like we did before)
- On Inspector set Parameter dropdown to Direction (it was Speed)
- (we are now at 21:00 in the video)
..to be continued..
Related Posts
7 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
Hello mgear,
I thought you’d like to know we just distributed a Beta release of the RAIN{indie} 1.3.4 with support for Mecanim. If you don’t have access to the Beta you can sign up for access and to receive news updates here:
http://rivaltheory.com/newslettersignup/
The full release should be available within a week or two from the Rival Theory website, and shortly after that from the Unity Asset Store.
Videos: RAIN and Mecanim Animations http://www.youtube.com/watch?v=AXN0c95yru8
RAIN and Mecanim IK: http://www.youtube.com/watch?annotation_id=annotation_949952&feature=iv&src_vid=AXN0c95yru8&v=ngxqeJ2HKFU
I look forward to hearing from you!
[…] animation that moves the root of the biped and an idle animation. You can look this up in billions of Mecanim tutorials on the […]
New mecanim demo scene from unity:
Mecanim GDC2013 Sample Project
https://www.assetstore.unity3d.com/#/content/9896
Crash Course Breakout – Mecanim
http://cgcookie.com/unity/cgc-courses/crash-course-breakout-mecanim/
Mecanim + AI [Free sources]
http://forum.unity3d.com/threads/238247-%28Advanced-ish%29-Mecanim-AI-Free-sources
rigging for mecanim with Cheetah3D:
http://c3dcookbook.com/wiki/index.php?title=Rigging_for_Mecanim
[…] Mecanim unity 4 tutorial (step-by-step from the video While looking at the new mecanim tutorial video, wrote down the steps from it (not finished yet) (huh – thats a lot of clicks just to get your robot moving. […]