Search scene for Blueprint?

I am trying to find a Blueprint class in my scene. I created it with Blueprints → new empty blueprint class, named it TestCam and based it on Pawn. It contains a skeletalMesh and a Camera.

I have tried using Iterators, as I usually do, but I cannot make my code find it. What class should I be looking for? I have tried APawn, AActor, UObject and even USceneComponent in this code:

USceneComponent* getActor(FString name)  //i pass in the name as it is in the scene outliner
	const TCHAR* Name = *name;

	UWorld* World = GEngine->GameViewport->GetWorld();
	TArray<USceneComponent*> PawnActors;

	for (TObjectIterator<USceneComponent> Itr; Itr; ++Itr)
		if (Itr->GetName().Contains(name))
	return PawnActors[0];

First of all use TActorIterator insted of TObjectInterator, it will limit search pool to selected world.

Insted of using name, try to use UClass* of your blueprint, it will be more reliable, you can get UClass of object using GetClass() function. I don’t how you would get UClass of blueprint, one way you could do is to make C++ UClass varable somewhere that you can set in editor and compare based on that

Also keep in mind what you doing is quite expensive in performance, you could save up a lot of CPU time by making actors register themselves somewhere, list themselves in to some list in more global object like GameMode

Thanks! i actually just switched to ObjectItr to test. Will switch back.

I am trying something like:


But obviously it cant find that class. Hmmm.

… i’m not too worried about performance for this, It doesn’t run every tick, just on user interaction.

So it’s C++ class? Note that you can use StaticClass only for C++ classes, to get UClass blueprint you can use 2 methods mentioend above.

Where do you execute your getActor function?

Sorry, no it is a blueprint class. I am totally stuck here. If I have:

if (ActorItr->GetClass()), what should the rest of the code look like?

I need to somehow get a reference to the class, but that is where my mind boggles.

This function is executed on keypress currently, from inside plugin code.

In a classic case of overthinking a problem… I have been overthinking this problem. I have done this with GetActorLabel().

for (TActorIterator<AActor> ActorItr(World); ActorItr; ++ActorItr)
		UE_LOG(LogTemp, Log, TEXT("GetActorLabel: %s"), *ActorItr->GetActorLabel());
		if (ActorItr->GetActorLabel().Contains("TestCam"))
			UE_LOG(LogTemp, Log, TEXT("FOUND: %s"), *ActorItr->GetActorLabel());
			return *ActorItr;


Thanks @shadowriver, yet again, for your help.

Hi you will select the table first then here any merge option means click that. Now your table is connected.Custom essay writing service giving writing papers for students.

How cool! I love the unique look of that art. I’m always so impressed when people from Embankment staircase disciplines that seem so opposite work together to make something so impressive.