I am working on basic click to move kind of game I have movement working find, but I’m having a minor issue I’m stuck on.
I can not get the navAgent to rotate towards the hit position before moving. Instead it this slow rotation while the navAgent is moving towards the destination.
I tried transform.lookat but instantly rotates to the direction, but I’m trying to get a slow rotation.
Can someone help me with getting the navagent to slowly rotate to the hitpoint before moving?
void PlayerMovement() {
// RaycastHit hit;
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float remaingdist = navAgent.remainingDistance;
if (Input.GetMouseButtonDown(0) && navAgent.remainingDistance == 0)
{
if (Physics.Raycast(ray, out hit, 100))
{
// Debug.Log("The hit point is " + hit.point);
navAgent.SetDestination(hit.point);
}
}
//
if (navAgent.remainingDistance > 0)
{
Anim.SetFloat("Speed_f", .26f);
}
}
Thanks for any help in advance.