How do i make the value pin be of the type that is returned?

I was testing some things in c++ and blueprint, and i saw the Get Component By Class node, and the return pin class changes based on the class that you select.

And i made a function in c++ with the same goal, but it just returns a SceneComponent, so i cannot use the StaticMesh functions.

Captura de tela 2024-07-12 152733

This is the Get Static Mesh code that i made, and it is a static function:

UActorComponent* ABaseItem::GetStaticMesh(const AActor* ActorToSearch, const TSubclassOf<UActorComponent> ComponentClass)
{
	UActorComponent* StaticMesh = ActorToSearch->GetComponentByClass(ComponentClass);
	return StaticMesh;
}

I went to the Get Component By Class code, but i couldn’t find anything that seems to make the node works that way.

Look at the meta DeterminesOutputType

Example:

UFUNCTION(BlueprintCallable, Category="Actor", meta=(WorldContext="WorldContextObject", DeterminesOutputType="ActorClass"))
static class AActor* GetActorOfClass(const UObject* WorldContextObject, TSubclassOf<AActor> ActorClass);
2 Likes

Thank you so much. I thought it could be a meta, but i didn’t know how to search.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.