- Home /
NavMesh Agent Controlled AI Sliding Toward next waypoint
Hey guys, I've got an AI that walks around the house patrolling, but i wanted to make it look more Authentic, at the moment he only faces the direction of his next waypoint, how can i make it so he faces the direction of which he is travelling.
i have Provided a video to show a demonstration of what happens, and to better help for a correct answer.
and this is the code i have for the Patrolling part of my AI Script.
 void Patrol()
         {
         runSound.enabled = false;
         walkSound.enabled = true;
         chasingMusic.enabled = false;
         anim.SetBool("isWalking", true);
         anim.SetBool("isRunning", false);
         anim.SetBool("isAttacking", false);
         agent.speed = patrolSpeed;
         agent.Resume();
         Vector3 direction = player.position - this.transform.position;
         direction = waypoints[waypointInd].transform.position - transform.position;
         agent.SetDestination(waypoints[waypointInd].transform.position);
         direction.y = 0;
         float angle = Vector3.Angle(direction, head.forward);
         if (Vector3.Distance(this.transform.position, waypoints[waypointInd].transform.position) >= 2)
             {
             agent.SetDestination(waypoints[waypointInd].transform.position);
             this.transform.rotation = Quaternion.Lerp(this.transform.rotation,
                                             Quaternion.LookRotation(direction), rotSpeed * Time.deltaTime);
             }
             else if (Vector3.Distance(this.transform.position, waypoints[waypointInd].transform.position) <= 2)
             {
                 waypointInd = UnityEngine.Random.Range(0, waypoints.Length);
             }
         }
is there no way to make an AI face the direction it is travelling?
Your answer
 
 
             Follow this Question
Related Questions
Checking if a non-walkable layer is blocking the path? (NavMeshAgent) 0 Answers
My NavMeshAgent doesn't move at all!,Why my NavMeshAgent doesn't move at all? 0 Answers
Player's last location as a Transform 1 Answer
Navemeshagent and doors 1 Answer
NavMeshAgent face same direction as destination point 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                