My Solution for getting X, Y, and Z to print

void UPositionReport::BeginPlay()


// ...
FVector TargetLocation = GetOwner()->GetTargetLocation();
FString ObjectName = GetOwner()->GetName();
UE_LOG(LogTemp, Warning, TEXT("%s is at X = %0.1f Y = %0.1f Z = %0.1f!"), *ObjectName, TargetLocation.X, TargetLocation.Y, TargetLocation.Z);


I created an FVector variable called TargetLocation, I initialized it with the return from GetOwner()->GetTargetLocation(). In the log string I used the formating code for printing a float to 1 decimal place %0.1f. Then used the X, Y, and Z members of the TargetLocation Variable.

1 Like

Highlight your code and press the </> button or surround your code with three `, as in:


I used the </> button, but for some reason it is leaving some of the code outside the code box. I didn’t notice that until after I had posted it :frowning:

Privacy & Terms