Long Route, but works for Actor Location

FVector Vect;

FString ObjectPosition = GetOwner()->GetTransform().TransformPosition(Vect).ToString();

UE_LOG(LogTemp, Warning, TEXT("Object %s Coordinates %s"), *GetOwner()->GetName(), *ObjectPosition);

Returns a huge number for Cube_5 when its location is actually -70 -250 70. So what’s happening? Looks like the negative numbers are being misinterpreted…:

LogTemp: Warning: This component is attached to Sphere_2
LogTemp: Warning: Object Sphere_2 Coordinates X=190.000 Y=250.000 Z=60.000
LogTemp: Warning: This component is attached to Cube_5
LogTemp: Warning: Object Cube_5 Coordinates X=10360576915510822246023168.000 Y=10360576915510822246023168.000 Z=10360576915510822246023168.000

What’s Vect?

FVector Vect; is the initialization above. TransformPosition() requires an FVector, so I just initialized one above this ObjectPosition statement.

  1. You most likely didn’t initialise it. FVector Vect; does not initialise the X, Y, and Z values of Vect.
  2. TransformPosition probably doesn’t do what you think it does. GetOwner()->GetTransform().GetLocation() is what you were after.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms