Does it work? Then it’s correct. In either case, you are getting the x,y,z of the transform. I found 3 main ways:
FString pos1 = GetOwner()->GetTransform().GetLocation().ToString();
FString pos2 = GetOwner()->GetActorLocation().ToString();
FString pos3 = GetOwner()->GetTransform().GetTranslation().ToString();
There is a subtle difference between GetActorLocation() and GetTransform().SomethingElse. Mainly, if you are only dealing with the location and don’t need the other elements that are on the transform, it is a little less typing and less referencing. GetTransform() gets you the entire component and everything that comes with it, while GetActorLocation is a shortcut to just the location you might be looking for.
I doubt there is much performance difference between these because of the compiler (if it were an interpreted language, GetActorLocation is calling less functions which would be faster).
The thing I’m not sure of is why there is both GetLocation() and GetTranslation() that seem to return the same values. The unreal docs are pretty terrible on this. GetTranslation “Returns the translation component”, while GetLocation gives you a “Temp function for easy conversion”.
Easy? I’m not learning C++ for easy! GetTranslation it is.