I’m trying to use the LookatTarget script within unity on a humanoid model so the head turns and looks at the player and tracks when the player is within a certain range of the model.
if(Vector.distance(target.transform.position, transform.position) < range)
Vector3 positionToLookAt = target.transform.position;
positionToLookAt = positionToLookAt - transform.position;
Quaternion lookRotaion = Quaternion.LookRotation(positionToLookAt, transform.up);
transform.localRotation = Quaternion.Lerp(transform.localRotation, lookRotaion, 0.2f);
I think this will work.