Find position of UStaticMeshComponent

I currently have a blueprint which has 3 static mesh components in it. Each of them is positioned and will be used to test for collisions. However, when getting the components in code, I can’t seem to find a way to get the location of them to do my distance check against:

TArray<UStaticMeshComponent*> comps;
ObjectsDummyPts->GetComponents(comps);

FVector point0Location = FVector(0, 0, 0);

// Doesn't work
comps[1]->GetComponenTransform().TransformPosition(point0Location);

// Run-time Error
AStaticMeshActor* theMeshActor = Cast<AStaticMeshActor>(comps[1]);
point0Location = theMeshActor->GetActorLocation();

float distance = FVector::Dist(point0Location, ObjToTestCollision->GetActorLocation());
if (distance < radiusCheck) ...

So is there any way to get the location of these UStaticMeshComponents from within code?

1 Like

You simple have to call GetComponentLocation() on your component. This will return world position.

There is some function available that will convert world to local, though can’t recall the name right now.

And you’re also trying to cast UStaticMeshComponent to AStaticMeshActor, that’s not gonna work, these are two different types.

1 Like

Not quite sure how I missed that one, but thanks!