Rotate AI Face Rotation

Hello This is Mahsa,

I have AI that walks towards a point and then stops, after that I want to look at another point just once
I know there is lot of solution out there but none of them working for me

  • To be more specific AI has a inner Graphic (AI Body ) and i want to rotate that not the player transform

If you are using a NavMesh Agent (from the to look at another transform, you can use the Transform.LookAt function to set the agent’s rotation based on the target transform’s position.

// The gameobject your Navmesh agent should be looking towards:
public Transform targetTransform;
// Calculate the direction from the agent to the target
Vector3 direction = targetTransform.position - transform.position;
// Rotate the agent to look at the target
transform.rotation = Quaternion.LookRotation(direction);