Hi,
My goal is to create an NPC character that turns and walks to a specified position. I’ve downloaded the Mixamo idle and walking animations and created a simple animator controller. When I run it, the NPC walks perfectly (flat on the ground and no sliding).
Now, I want to get it to turn and walk towards a specified position. Here’s what I tried:
- Created a NavMesh surface on my plane (there are no obstacles).
- Added a Nav Mesh Agent to my character.
- Disabled Apply Root Motion on the animator controller.
- Wrote a simple script:
void MoveToTarget()
{
agent.SetDestination(target.position);
agent.isStopped = false;
}
// Update is called once per frame
void Update()
{
if (target)
{
MoveToTarget();
}
}
Now, the character floats above the nav mesh and slides along the ground as the animation walking is not in-sync with the character movement.
Questions
Why is it floating?
Is this the best approach to get what I want?
Should I even be using a nav mesh at all, or could this be done with a character controller script?
Thanks for your time.