Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by LeftyTwoGuns · Apr 05, 2014 at 04:02 AM · animationmecanimmoveroot motionwalk

How do I move a model with its walk animation?

I'm a little confused about getting a rigged model to move with its walk animation. First I created a walk cycle in Blender that just walks in place. Import everything into Unity just fine and set it up through Mecanim. The character walks when I press the proper input but it doesn't move. Here's the script I used:

 public class Locomotion : MonoBehaviour {
 
     Animator anim;
 
     // Use this for initialization
     void Start () {
 
         anim = GetComponent<Animator>();
     
     }
     
     // Update is called once per frame
     void Update () {
 
         float move = Input.GetAxis("Vertical");
         anim.SetFloat("Speed", move);
     
     }
 }


Then I figured maybe the rig actually has to move in Blender. So I do another walk cycle of the rig physically walking forward and import that. Except, the model will walk forward then rest back to the original position. Setting it to loop makes the model walk in place.

What am I missing in this process?

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LeftyTwoGuns · Apr 06, 2014 at 01:42 AM 0
Share

Anyone have any input?

I could've sworn there was an extra step you had to take in Unity to get a walk cycle working correctly and I thought it was in Unity's mecanim tutorial but I just watched it again and didn't see anything like that.

avatar image getyour411 · Apr 06, 2014 at 01:47 AM 0
Share

From what I know of $$anonymous$$ecanim, unless you've done something special in your Blend Tree, what you've described is normal for the first Blender/walk in place; you still have to tell the gameobject to "$$anonymous$$ove" which can be done in many different ways (rigidbody force, transform.translate, CC/move/simplemove, etc)

It might help to know exactly what you setup 'Speed' to be in your $$anonymous$$ecanim BlendTree.

avatar image LeftyTwoGuns · Apr 06, 2014 at 02:28 AM 0
Share

Speed is a float which initiates the Walk animation when it exceeds 0.10. Which happens but the character doesn't move forward. I thought the root motion would make the model move according to its animation, unless I'm misunderstanding how that works

avatar image getyour411 · Apr 06, 2014 at 03:08 AM 1
Share

See if any of this helps

https://docs.unity3d.com/Documentation/$$anonymous$$anual/Root$$anonymous$$otion.html

In my limited use of $$anonymous$$ecanim so far, I've still done the moving with code rather than built-in which sounds like what you are trying to achieve with the second cycle

avatar image LeftyTwoGuns · Apr 06, 2014 at 07:10 PM 0
Share

Alright, I looked over those settings and then the Root $$anonymous$$otion settings of the $$anonymous$$ecanim tutorial and I got it working now. Thanks for offering some help even though you're not completely familiar with the subject. Greatly appreciated

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GEWLAR · Apr 08, 2014 at 01:11 PM

The Animation should move at the place that's right. To actually move the Object you have to write a script which realy changes its location (look at the standard assets for that).

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image getyour411 · Aug 15, 2015 at 01:44 AM 1
Share

...unless you are using Root $$anonymous$$otion. Unlike a normal clip where movement is via script/CC/physics etc and the clip is just a play-in-place, Root$$anonymous$$otion mecanim clips move the actual player.

avatar image
0

Answer by Pheonix · Mar 23, 2016 at 11:00 AM

ADD a rigid body and use following script on your player game object.

 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour
 {
 
 //the speed you want your player to move with.
     public float speed;
 
     void FixedUpdate ()
     {
 
 //This will allow you to move your character using unity default keys (WASD or arrow keys)
         float moveHorizontal = Input.GetAxis ("Horizontal");
         float moveVertical = Input.GetAxis ("Vertical");
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
         rigidbody.velocity = movement * speed;
 }
 }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[Mecanim] Turning animation doesn't rotate the whole way 1 Answer

Root Motion issue 1 Answer

How to make enemy run animation 3 Answers

How to fix this Mechanim root motion problem? 0 Answers

Mecanim Issues: Root motion not being applied, and weapon is out of place 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges