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.