In Unity, how to prevent animations from messing with the movement?
Asked Answered
G

2

0

The problem:

I have a character model with a Nav Mesh Agent component. It moves perfectly well to any destination I tell it to move (using the NavMeshAgent.destination property).

But this suddenly fails as soon as I use an animation controller I downloaded from the store. The character won't run to it's destination; instead, it will endlessly run around it in circles.

I'm not sure why this happens, but I suppose the running animation somehow cripples the character's ability to turn. The Inspector, in the import setting of the relevant .fbx file shows: Average Angular Y Speed: 0.0 deg/s.

What I really, really fail to understand is why this keeps happening even though I have explicitely set NavMeshAgent.updatePosition and NavMeshAgent.updateRotation properties to true. The way I understand the documentation, this should make the character move as the Nav Mesh Agent wants it to move, and not as anything else (animations included) wants it to move?

How should I fix this problem? How should I force the animation not to meddle in the movement?

Gravitate answered 22/4, 2016 at 0:50 Comment(0)
S
2

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.

Strapper answered 22/4, 2016 at 3:56 Comment(2)
Thank you, kind Sir. Checking off Apply Root motion worked like a charm. But, if I may ask, why did NavMeshAgent.updatePosition and NavMeshAgent.updateRotation have no effect?Gravitate
Hi @Milad Qasemi ! 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.Keening
C
0

First: one of the biggest plus of Unity is its mecanim. Disabling root motion is negating a big advantage.

Second: the reason your character is running around probably is because the animator and the navmesh agent are issuing conflicting orders. Use updatePosition to false and updateRotation to true. Hence, the animator controls how fast you move and the navmesh agent controls the angular speed. Other posible cause is that your destination is unreachable. Check the Y component of the vectors and insure they are coplanar.

Carpetbagger answered 13/9, 2016 at 4:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.