I aimed to ge the : but it takes a bit more space

So I got the floatvalues for x,y and z in order to show them as
GameObject is at position X: ValueOfX Y: ValueOfY Z: ValueOfY

FVector ObjectVector = GetOwner()->GetActorLocation();
UE_LOG(LogTemp, Warning, TEXT("%s is at position X: %f, Y: %f, Z: %f"),
*ObjectName,
GetOwner()->GetActorLocation().X,
GetOwner()->GetActorLocation().Y,
GetOwner()->GetActorLocation().Z);

1 Like

How do you feel about your code?

I do like it but I realised after posting that I could replace the GetOwner()->GetActorLocation() with ObjectVector inside the UE_LOG or remove the entire line “FVector ObjectVector = GetOwner()->GetActorLocation();”

And the alternative looks a bit more clean. Also I do like that I get the independent values for future usage. But it really depends on the end goal.
Alternative:
FVector ObjectVector = GetOwner()->GetActorLocation();
UE_LOG(LogTemp, Warning, TEXT("%s is at position X: %f, Y: %f, Z: %f"),
*ObjectName,
ObjectVector.X,
ObjectVector.Y,
ObjectVector.Z);

Privacy & Terms