Hey there! Hope that you are doing well.
My question is that, in video number; 169. Rotate to face Target
, we have used this function for rotation of enemy towards player :
void FaceTarget()
{
Vector3 direction = (target.position - transform.position).normalized;
Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z));
transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * turnSpeed);
}
So my question is, can we use LookAt
method in place of this whole big function as compared to LookAt
method?
I’m asking this because LookAt
method does the same work as the FaceTarget
method and I’m concerned about it, whether it will give me any errors in future or not.