Trying to understand relationship in a turret Rotation

I’m trying to understand how this piece of code works regarding how a turret updates its rotation.

The code in question:

var targetPoint = target.position;

var targetRotation = Quaternion.LookRotation (targetPoint - transform.position, Vector3.up);

transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.0);

I think the targetPoint - transform.position is how it generates the rotation value relative to its current position; I’m wondering if the value it generates would go to zero given that its target stopped moving.

I’m thinking it generates a positive or negative number depending on the rotation adjustment required, but again I’m not entirely certain.

Thanks, and I can post more from the script if this isn’t clear enough for my question.

targetRotation is a Quaternion which given this code represents the rotation that would make the current game object face the target. Put another way, if you did not execute the second line above but instead just did…

transform.rotation = targetRotation;

…the code would behave just like Transform.LookAt(). The game object would immediately look at the object. targetRotation is not an adjustment to the current rotation. If you were to…

Debug.Log(targetRotation.eulerAngles);

…you would get back angles that if assigned to the rotation in the inspector would point the game object at targetPoint;

The Quaternion.Slerp() is what causes the rotation to occur over time.