So I need to move an object in a circle and found this code HERE. I’ve tried the code and it works. I just need an explanation on some lines, specifically this lines:
var worldLookDirection = target.position - transform.position;
var localLookDirection = transform.InverseTransformDirection(worldLookDirection);
The ‘target.position’ is the position of the center of the circle right? Then why did he subtracte it to the object’s position and why did he used ‘InverseTransformDirection’? Isn’t the direction already in local space?(I’m not sure though).
Last is this line:
transform.forward = transform.rotation * localLookDirection;
My Question why did he need to change the object’s forward?
Also, what if I want to adjust the distance/radius between the object and the center?
Thanks in advance!