CDO Constrcutor failed to find blueprint class. Why?

I am tearing my hair out over this one now, after spending literally hours trying to uncover the problem.
I am having some difficulty using the ConstructorHelpers to find a blueprint.

	static ConstructorHelpers::FClassFinder<ASpaceApeMenuPlayerController> Controller(TEXT("/Game/GameBlueprints/PlayerControllerMenu_BP"));

	if (Controller.Class != NULL)
	{
		PlayerControllerClass = Controller.Class;
		//UE_LOG(LogTemp, Warning, TEXT("SetController"));
	}

The really irritating thing is, that it works elsewhere for a different blueprint.

	static ConstructorHelpers::FClassFinder<APlayerController_SpaceApe> Controller(TEXT("/Game/GameBlueprints/PlayerController_SpaceApe_BP"));

	if (Controller.Class != NULL)
	{
		PlayerControllerClass = Controller.Class;
	}

Could someone tell me why one would work, but the other does not?
(preferably before I go crazy =P)

I had already fixed the redirectors, so that didn’t seem to make a difference.

I’m pretty sure the path is correct, so it must be that the parent class is different, but I’ve since made another blueprint class that inherits from the same C++ class and tried to find that, but had the same issue.

I’m just ditching the blueprints and going full C++, which was the plan all along anyway. They’re nothing but trouble. =P

Thanks for the response anyway.

Only plausible reasons for it to fail I can think of are 1) The path is wrong; 2) The blueprint exists, but doesn’t derive from the class you specified as the template argument.

You could maybe try fixing up redirectors in the folder first in case you changed the blueprint name, but I’m fairly sure FClassFinder should deal with that correctly anyway.

Though it’s not an answer to your question, I’d recommend avoiding hard coded blueprint paths in favour of adding a TSubclassOf (or TAssetSubclassOf if you can load it only when needed) property to the class, which you then set within the editor. It’s much more robust.

Use

ConstructorHelpers::FObjectFinder<UClass>

with the blueprint class string, e.g.

/Game/Blueprint/MyObject.MyObject_C

.

1 Like

Dude, thank you for this.