Hi…What i want to do is to create a Mecanim Controller which is driving by a NavMeshAgent AI… and sending both speed and angle from the AI to the Mecanim Controller… i have tried the learning project “Stealth” to make the script…but when the player is near the object that i want it to follow… the player will bounce from x to z random points then stops… this also happens when the object gets a new longer distance and the player starts bouncing again and move to the object…any idea?
3 Answers
3Don’t let the NavMeshAgent control movement. Instead pass this variable to mecanim to allow root motion to work/move the object.
Never used OnAnimatorMove myself, but it looks like that's post-movement, and if I'm not mistaken, you're trying to tell Mecanim how fast to move based on the NavMeshAgent? So when, for instance, player is within the range of the enemy, enemy's NavMesh is turned to active, and then the desiredVelocity is sent to mecanim as a float variable (likely called "velocity" if you follow the standard conventions). Root motion takes hold from that, moving your character forward.
– infinitypbrBut i want the Animations to set the velocity of the AI.. what if i have some sort of a zombie walk? when speed is like : 1>>0.1>>0.4>>1>>0 ... all in the root motion... i want the NavMesh to be driven by the RootMotion.
– Shkarface-NooriHas anyone figured out a way to do this yet? I have been banging my head for days trying to get animations to control velocity with mechanim and navmesh.
– JaqalThat happened to me too, i guess is because the animation, that moves forward on the axis, so the character goes straight from the point, and try to go back and goes straight several times.
If you disable the animation, and let the agent handle the movement and rotation, this doesn’t happen.
I’m trying to figure out the best way to use the agent with the mecanism too, if you know something let me know. =)
Or try to let the NavMeshAgend controll the position but dont apply root motion from your animations.
var animator = GetComponent<Animator>();
animator.applyRootMotion = false;
You may also have a look into your AnimationClips you are using and, set each Root Transformation setting to use “Original” positions from your animations. See here.
Doing so for my animations had solved this kind of trouble.
(A little bit late but it might help someone else
)
Sounds like a scripting problem, can you post your code?
– infinitypbr