I have the following hierarchy in my project:
In my code, I’m trying to get the global translation of both MarioSprite and Camera, get a vector that points towards the camera, and then get the angle.
MarioVector := MarioSprite.LocalToWorld(MarioSprite.Translation);
CameraVector := Camera.LocalToWorld(Camera.Translation);
DiffVector := CameraVector - MarioVector;
DiffVector := Vector3(DiffVector.X, 0, DiffVector.Z);
Percent := AngleRadBetweenVectors(Mario.Direction, DiffVector) / (Pi * 2);
However, the code will error at the AngleRadBetweenVectors call, stating that one of the vectors is zero.
After logging MarioVector and CameraVector, I discover that they are the exact same, which causes DiffVector to be zero.
In the scene, Camera and MarioSprite are not at the same translation. However, both of their parents (Mario and SwingArm) are the same. Which leads me to think LocalToWorld is actually just getting the translation of the parent.
But I thought LocalToWorld would get the global (world) translation of the transform. Is this the right procedure for this? Or is there another way I should be converting local translation to global?