UBlueprint & USCS_Nodes, absolute node location or component heirarchy?

This seems like it should be obvious, but I have browsed around in the code and I’m just not seeing it. It’s probably staring me in the face…

I just want the absolute location of a node/component, but everything seems to be 0 except GetRelativeLocation(). So decided to just back up the tree and calculate it, except the only way I could make it work is a huge hack. Anyone have a pointer to some engine code or know off hand how this should work?

Here is the gist of what I’m doing. Example actor I’m using has 3 static mesh components, 1st child of root, 2nd child of 1st, 3rd child of 2nd


UBlueprint* bp = Cast<UBlueprint>( a FAssetData that is an actor );
TArray<USCS_Node*> AllNodes = bp->SimpleConstructionScript->GetAllNodes();
for(auto& n : AllNodes) {
    USceneComponent* sc = Cast<USceneComponent>(n->ComponentTemplate);
    //this are 0
    sc->GetComponentLocation
    //this is correct
    sc->GetRelativeLocation

    //these are 'None'
    n->ParentComponentOrVariableName.ToString()
    n->ParentComponentOwnerClassName.ToString()
    //this is null
    n->GetParentComponentTemplate(bp)
}

The working bit that retrieves the parent is a horrific hack. It searches AllNodes using IsChildOf(). It has to get the last one that isn’t itself since node->isChildOf(node) is true. Here’s the horrific hack test code… don’t judge it’s exploratory!


FVector GetParentsRelativeLocations(UBlueprint* bp, TArray<USCS_Node*> AllNodes, USCS_Node* node) {
    USCS_Node* p = nullptr;
    for(auto n : AllNodes) {
        if((n != node) && (node->IsChildOf(n))) {
           p = n;
        }
    }
    if((p == nullptr) || (p->ComponentTemplate == nullptr)) return FVector::ZeroVector;
    USceneComponent* sc = Cast<USceneComponent>(p->ComponentTemplate);
    if(sc == nullptr) return FVector::ZeroVector;
    UE_LOG(LogTemp, Warning, TEXT("Parent.sc.FName=%s"), *sc->GetFName().ToString());
    return sc->GetRelativeLocation() + GetParentsLocation(bp, AllNodes, p);
}