Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by gaazkam · Apr 20, 2016 at 03:39 AM · animationmovementnavmeshagent

How to prevent an animation from interfering with NavMeshAgent movement?

I downloaded a simple asset from the store that is supposed to provide some animations for humanoid characters. It comes with an animation controler (Mecanim).

The problem: I can't use it with NavMeshAgent. As long as the animation is set to Idle, everything works fine - after issuing NavMeshAgent.destination = somegoal my character runs (er.. slides) to that goal and stops.

But if I set the animation to make the model run, my character will no more reach its goal, but rather it will run circles around it endlessly.

What I really, really fail to understand is why this keeps happening even though I explicitely set NavMeshAgent.updatePosition and NavMeshAgent.updateRotation to true? The way I understand the documentation, this should force the character to move as the NavMeshAgent wants it to move, not as the animaiton wants it to move!

Here's my very simple code:

 public class MoveDestination : MonoBehaviour {
 
     public Transform goal;
 
     private NavMeshAgent agent;
     private Animator animator;
 
     void Start () {
         agent = GetComponent<NavMeshAgent>();
         animator = GetComponent<Animator> ();
         agent.updatePosition = true;
         agent.updateRotation = true;
 
         agent.destination = goal.position;
         animator.SetBool ("Moving", true);
         animator.SetBool ("Running", true);
     }
 
     void Update() {
         if (agent.remainingDistance == 0) {
             animator.SetBool ("Moving", false);
             animator.SetBool ("Running", false);
         }
     }
             
 }

How to fix this?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by gaazkam · Apr 23, 2016 at 03:26 PM

The correct answer to this problem comes from StackOverflow, http://stackoverflow.com/a/36784543/4385532 . It reads:

Do all your animation in place and use code to do the movement and you can uncheck root motion and use state machine values to get a better movement or use root motion and let mecanim`s retarget engine do the blending so go see for yourself what gets you better result , so I guess your problem is that your animation are not in place.

Yes, unchecking Apply Root Motion worked for me like a charm.

Comment
Add comment · Show 2 · 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 _gord0_ · Jun 17, 2017 at 07:46 AM 0
Share

I'm having a similar issue except my Animator says Handled By Script in the place where I should be able to uncheck root motion. Not having much luck googling.

avatar image Kotlarska · Aug 09, 2018 at 09:13 PM 0
Share

I unchecked root motion and set my animation as "In place". the character is now animated but it doesn't move from point A to point B. RigidBody.movePosition(...) stopped working.

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

94 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 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 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 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

Having issues with teleporting forward 0 Answers

Animations get screwed up when I add OnAnimatorMove function 0 Answers

My player does not turn around 0 Answers

Mecanim Generic No movement 0 Answers

´How to check if 3D player is moving? 0 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