简体   繁体   中英

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

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?

难道全部到位动画并使用代码做运动,你可以取消根运动和使用状态机值来获得更好的运动或使用root运动,让mecanim`s重新定位引擎做混合所以要看到自己得到了什么您可获得更好的结果,所以我想您的问题是动画不到位。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM