Okay, so I know that I can have an object rotate towards another object by this code, but I don’t know why it works and I can’t seem to just leave it alone and accept that it does what it does without knowing why and where my error in thought is.
If I minus the players coordinates, let’s say they’re 5,1,7 from the objects coordinates, let’s say they’re 3,5,8 I get
-2,4,1, which is not actually where my player object is… Why then does this word whereas just telling the program to look at the player gives strange results? I’m obviously missing something here.
So first things first. A vector is not a point in space but rather a point and a direction. When it’s used as a point in space it’s in actuality a vector pointing from the world origin to the point in space. So - subtracting a vector from another vector gives you a vector that points from one to the other. In this case, pointing from transform to player.
Slerp is short for spherical interpolation. Lerp is short for linear interpolation. Both operate in a manner of Slerp(A, B, P) which interpolates from A to B by the percentage amount of P. So 0 is A and 1 is B and 0.5 is halfway between A and B. Therefore, you could simplify your code and remove the Slerp entirely.