Walking Components

how to inspect and walk the Actor Component Hierarchy

This page covers how to walk the Actor Components s in a 3D Level akin to the Details panel:

Compared to the Actor Hierarchy, Components appear deceptively simple to iterate over with a recursive function:

def walk_component(component, indent=2):
    """walk the given component to print its hierarchy"""
    print(f"{' '*indent}{component.get_name()}")

    # recurse through any immediate children
    for child in component.get_children_components(False):
        walk_component(child, indent+2)

After getting our Actor reference, we can start from the root_component reference:

If we compare the results of this function to the Details Panel, we'll notice quite a few extra lines:

This is because the function_test Blueprint Asset spawns child actors. If we only want to view the immediate components of our given actor we can add a get_owner() check to confirm the component is directly managed by the given actor:

This added step gives us a printout that better matches the Details Panel:

Last updated