Hi all,
I’ve been scratching my head for at least 2 hours and a half trying to deal with NavMeshAgent and Animator components. The issue comes in where the Animator can move, and so can NavMeshAgent (Making the model move further than the original navmesh position).
Instead, I’m trying to code in it’s precise path direction and then have the animator move towards it. To do that, I have to use NavMeshAgent.nextPosition, to find the target to go after.
But rather than giving me the direction, it gives me the Vector3 of where the player is exactly. I checked the documentation and it stated that it was suppose to give me the target direction in which navmeshagent needs to go. Am I’m doing something wrong?
Here’s what the code looks like
void Movement(Vector3 destination, float speed)
{
navAgent.SetDestination( destination );
navAgent.speed = 0;
//Find a way to get vector of directions to destination area from NavMeshAgent
float angle = Vector3.Distance( transform.position, navAgent.nextPosition );
//Requires Animator!
anim.SetFloat( "Speed", speed );
anim.SetFloat( "Direction", angle );
}