srry for long response.
but from here, i see its kind of to smooth da angle, lik, u can in his vid, da head wont directly look up to mouse point, but somewhere below, dis is bc of da :Cross() func.
tell me if im stoopeed and got thigs wrong, i will only be taught about 3d stuff next 2 years
well, you can see in Cleversource’s algorithm that the yaw angle was calculated by the Y component of the cross product which are equal to each other. Why is this the case?
cframes are a 4x4 lookat matrix but we can only access the non homogenous portion so thats where the 3x3 comes from. Remember they are unit vectors so it is gonna just be some value on the unit circle aka radians aka angle
For this explanation, I will be working in 2D (because it’s easier). The same principles apply to 3D though.
(HeadPosition - Point)
Get HeadPosition relative to the point.
Imagine drawing an arrow from the Point to the HeadPosition:
and then moving that arrow to the centre of the world.
(HeadPosition - Point).Unit
Now, imagine shrinking that arrow down so its length is just 1.
((HeadPosition - Point).Unit):Cross(TorsoLookVector)
Now get the cross product of this vector and whatever TorsoLookVector is.
But hold on, what is a cross product?
A cross product is defined by a vector that is perpendicular to two vectors. from Wikipedia
I don’t actually know why this works. Maybe you can do more research.
The length aka y value of a cross product is the area or in other words how much the vectors you multiplied it by relate, the area of the parallelogram they form. You are getting the cross product of 2 unit vectors. What this means is the max this length can be is 1, when they are at 90 degrees cause a square is base*height, 1 x 1 = 1. However you actually get a null vector (a vector with no magnitude) when they are facing parrallel to each other. Look lets just get rid of all this math jargin behind, it is basically the opposite of a dot product angle calculation. If you used a dot product for this when they are orthogonal you would get 1 or -1, in this you get 0 and vis versa. That *1 is probably to get rid of floating point errors I heard somewhere a while ago it somehow magically fixes them in lua
I forgot to mention this makes no sense in your case if you dont get this value and do math.deg(math.acos(value)) where value is your y thing
ok but that is quite confused, i don’t mean to offend you but it just makes no sense at all. It is not relevant to the question? WDYM by the opposite of a dot product angle calculation? Can you pls explain it more?
I looked at his code a bit more he basically wants to know how to get the y angle (horizontal sorta) between the vector formed from the point to the players head and the players torso. So lets say the player was facing directly at it, it would mean that his returned value would be 0, but lets say it was on the side of their ear, the y rotation would be 1 on the graph***
And can you visualize the Y component of a cross vector in 3D environment following x,y,z axis? It is for me to easier understand how the Unit Circle form in the 3D environment