Understanding FRotationMatrix::MakeFromX

I needed to rotate an object to the player and I looked at the blueprint code from the Blueprint office because I remembered that they had those info tables. It uses MakeFromX to rotate an object always to the player.

I am not sure if I understand the math behind it. I give it a vector that goes from the object to the player and it calculates a rotation matrix that rotates the object to the player.

But all it does is really creating two orthonormal vectors from the object-to-player vector and puts it in a matrix. How can that be the correct rotation? And it also seems to rotate around the Z and Y axis.

I hope someone can enlighten me.

Okay I think I understand the math behind it. If you write the vectors in the rows it is the same as the dot product for every vector.

I am not 100% sure but I think it creates a matrix that describes an orthonormal basis in 3d-space where the provided vector is the X-Axis.

You might also want to look at functions like FRotationMatrix::MakeFromXZ. That will point X (forward) in the direction you want, and Z (up) will be changed as much as needed to be orthogonal to X. That way you can specify which direction to try and keep ‘upright’ in your rotation.

thats very good to know. thx James