Relative Location

Hello,

I have an custom AActor with a UStaticMeshComponent and I’m just trying to get the relative location of that component in BeginPlay.

FVector v = MeshComp->RelativeLocation;

UE_LOG(LogTemp, Log, TEXT(“RelativeLocation: %.2f, %.2f, %.2f”), v.X, v.Y, v.Z);

v = MeshComp->GetComponentLocation();

UE_LOG(LogTemp, Log, TEXT(“GetComponentLocation: %.2f, %.2f, %.2f”), v.X, v.Y, v.Z);

v = GetActorLocation() - MeshComp->GetComponentLocation();

UE_LOG(LogTemp, Log, TEXT(“GetActorLocation - GetComponentLocation: %.2f, %.2f, %.2f”), v.X, v.Y, v.Z);

These are the logs:

LogTemp: RelativeLocation: -64.38, 1054.12, 245.28

LogTemp: GetComponentLocation: -64.38, 1054.12, 245.28

LogTemp: GetActorLocation - GetComponentLocation: 0.00, -20.00, 0.00

The actual relative location is 0, 10, 0.

90176-capture.png

I cannot believe I am asking this, but how… do you get the relative location of a component in code… ?
So many small bugs and issues I find every day in UE4… I am at my wit’s end, I don’t understand how anybody is able to create anything with this tool… Maybe nobody uses the relative location… Please help…

v = GetTransform().InverseTransformPosition(MeshComp->GetComponentLocation());

UE_LOG(LogTemp, Log, TEXT(“InverseTransformPosition: %.2f, %.2f, %.2f”), v.X, v.Y, v.Z);

Log:

LogTemp: InverseTransformPosition: 0.00, 10.00, 0.00

…I don’t like UE4

ChildComponent->GetRelativeTransform().GetLocation()