Using GetActorLocation() without using ToString() hint

This is how I did it without using the .ToString() hint provided.

FString objectName = GetOwner()->GetName();
FVector objectPosition = GetOwner()->GetActorLocation();
UE_LOG(LogTemp, Warning, TEXT("%s: X=%f Y=%f Z=%f"), *objectName, objectPosition.X, objectPosition.Y, objectPosition.Z);

That’s how I did it as well.

That’s great! On the other hand, the ToString() function can make your code more compact and readable, while also standardizing the way to print a vector and sparing you from copying-pasting-modifying the format string and parameters every time you wish to print a vector.

Privacy & Terms