# Problems Trying To Generate List Of Component Socket Pairs In Actor Component

**URL:** <https://forums.unrealengine.com/t/problems-trying-to-generate-list-of-component-socket-pairs-in-actor-component/2000245>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [August 31, 2024, 11:23pm UTC](https://forums.unrealengine.com/t/problems-trying-to-generate-list-of-component-socket-pairs-in-actor-component/2000245 "2024-08-31T23:23:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jswanson993](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jswanson993](https://forums.unrealengine.com/u/jswanson993)\
**Post date:** [August 31, 2024, 11:23pm UTC](https://forums.unrealengine.com/t/problems-trying-to-generate-list-of-component-socket-pairs-in-actor-component/2000245/1 "2024-08-31T23:23:53Z")

</div>

Hello, I feel like I am trying to do something impossible, but I want to see if anyone has any insights anyways. I am trying to create a hit detection component and allow the user to specify what sockets they want to use for tracing. I’ve setup a struct with a component name and socket name property and I’m trying to use the GetOptions meta specifier to generate an array of names for the components.

```auto
	UPROPERTY(EditDefaultsOnly, DisplayName="Component", meta=(GetOptions="HitDetection.HitDetectionComponent.GetOwnerComponents"))
	FString ComponentName;
	UPROPERTY(EditDefaultsOnly)
	FName Socket;

```

I found a function from [this post](https://forums.unrealengine.com/t/how-to-get-a-component-from-a-classdefaultobject/383881/5) that gets all the components from a blueprint generated class. Here is my slightly modified version:

```auto
TArray<FString> UHitDetectionComponent::GetOwnerComponents()
{
	UObject* OwnerObject = GetOwner();
	TArray<FString> Result = {};

	UBlueprintGeneratedClass* BlueprintGeneratedClass = Cast<UBlueprintGeneratedClass>(OwnerObject);
	UE_LOG(LogTemp, Warning, TEXT("Gets here"))
	if (!BlueprintGeneratedClass) return Result;
	UE_LOG(LogTemp, Warning, TEXT("Gets here too"))
	
	TArray<UObject*> DefaultObjectSubobjects;
	BlueprintGeneratedClass->GetDefaultObjectSubobjects(DefaultObjectSubobjects);

	// Search for ActorComponents created from C++
	for (UObject* DefaultSubObject : DefaultObjectSubobjects)
	{
		if (DefaultSubObject->IsA(USceneComponent::StaticClass()))
		{
			Result.Add(DefaultSubObject->GetName());
		}
	}
        
	// Search for ActorComponents created in Blueprint
	for (USCS_Node* Node : BlueprintGeneratedClass->SimpleConstructionScript->GetAllNodes())
	{
		if (Node->ComponentClass->IsChildOf(USceneComponent::StaticClass()))
		{
			Result.Add(Node->GetVariableName().ToString());
		}
	}
        
	return Result;
}

```

The problem is it requires a call to GetOuter() which isn’t allowed for static classes (Since I’m using a struct the GetOptions needs to point to a static function).

I tried to set a static OwningObject variable in the constructor but it seems to fail to cast it to a UBlueprintGeneratedClass.

I also tested with just an internal string using non static functions and it works just fine, but I can’t pair the socket names with that.

Any Suggestions?

Thanks
