I am working with nav mesh agent, I have a plane in a 3D world with a baked nav mesh,
I have enemys(Zombies) that follow the player with a nav mehs agent,
It is working the problems cames when they is arriving at destination, for some reason they start to rotating ( see image ) ( unity don’t let me upload , so I uploaded in an external site)
I tryed to put the Y value of the enemy but It didn’t work
target = GameObject.FindGameObjectWithTag("PlayerTarget").transform;
Vector3 destination = new Vector3(target.transform.position.x, transform.position.y, target.transform.position.z);
navMeshAgent.destination = destination;
Any Idea will be welcome
Update fuction
public void Update()
{
float speed = Vector3.Project(navMeshAgent.desiredVelocity, transform.forward).magnitude;
animator.SetFloat("Speed", speed);
if (currentEstado != Estado.Death)
{
if (target != null)
{
currentEstado = Estado.Running;
transform.LookAt(target);
if (Vector3.Distance(transform.position, target.position) <= navMeshAgent.stoppingDistance)
{
currentEstado = Estado.Attacking;
if (Time.time > nextAttackTime)
{
Attack();
nextAttackTime = Time.time + msBetweenAttacks/1000;
}
skinMaterial.color = Color.red;
}
}
else
{
currentEstado = Estado.Idle;
}
}
AnimarEstado();
}