Can't i use more than one FObjectFinder(UBlueprint) in the same project?

Hi,

Not sure if it’s me not understanding something or a bug.

In my gamemode.cpp i declare the following:

static ConstructorHelpers::FObjectFinder<UBlueprint> PlayerControllerObjet(TEXT("Blueprint'/Game/player/BP_YagPlayerController.BP_YagPlayerController'"));

In my playercontroller.cpp i declare the following:

static ConstructorHelpers::FObjectFinder<UBlueprint> BP_YagPlayerObject(TEXT("Blueprint'/Game/player/BP_YagPlayer.BP_YagPlayer'"));

If only one is commented (//), i can compile and open the editor.

But if both are uncommented, i can compile, but i get a crash when trying to open the project.

Both references come from the “copy reference” in the editor (R-click on the BP), so they are correct.

Am i doing anything forbidden ?

Here are some parts of the crash reporter message:

[...]
Unknown exception - code 00000001 (first/second chance not available)
Assertion failed: Export.Object == NULL [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.5\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp] [Line: 3111] 
[...]
UE4Editor_yag!ConstructorHelpersInternal::FindOrLoadObject<UBlueprint>() + 552 bytes [c:\program files\unreal engine\4.5\engine\source\runtime\coreuobject\public\uobject\constructorhelpers.h:31]
UE4Editor_yag!ConstructorHelpers::FObjectFinder<UBlueprint>::FObjectFinder<UBlueprint>() + 192 bytes [c:\program files\unreal engine\4.5\engine\source\runtime\coreuobject\public\uobject\constructorhelpers.h:91]
UE4Editor_yag!AyagGameMode::AyagGameMode() + 77 bytes [c:\users\cedric\documents\unreal projects\yag\source\yag\yaggamemode.cpp:12]
[...]
UE4Editor_Projects + 85014 bytes
UE4Editor!FEngineLoop::LoadStartupModules() + 71 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.5\engine\source\runtime\launch\private\launchengineloop.cpp:1754]
UE4Editor!FEngineLoop::PreInit() + 9213 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.5\engine\source\runtime\launch\private\launchengineloop.cpp:1310]
UE4Editor!GuardedMain() + 236 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.5\engine\source\runtime\launch\private\launch.cpp:112]
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.5\engine\source\runtime\launch\private\windows\launchwindows.cpp:125]
UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.5\engine\source\runtime\launch\private\windows\launchwindows.cpp:201]
UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]

If anyone can edit the title of my question, i meant:

FObjectFinder<UBlueprint>

and not just:

FObjectFinder

But the UBlueprint disappeared from the question.

I edited it for you

:heart:

Rama

#Yes

Btw the answer is yes!

Here’s a bit of code from my Game Mode class

The trick of it is you just have to use different names for the objects and you’ll be fine!

ex: PlayerPawnOb vs. TheHUDOb

//Character
	static ConstructorHelpers::FObjectFinder<UBlueprint> PlayerPawnOb(TEXT("Blueprint'/Game/Characters/JoyGemBP.JoyGemBP'"));
	if (PlayerPawnOb.Object != NULL)
	{
		DefaultPawnClass = (UClass*)PlayerPawnOb.Object->GeneratedClass;
	}
	
	//HUD
	static ConstructorHelpers::FObjectFinder<UBlueprint> TheHUDOb(TEXT("Blueprint'/Game/Player/JoyHUDBP.JoyHUDBP'"));
	if (TheHUDOb.Object != NULL)
	{
		HUDClass = (UClass*)TheHUDOb.Object->GeneratedClass;
	}

:slight_smile:

Rama

Thank you Rama, both for the editing and to take the time to answer :slight_smile:

I am already using different names, but at least i know this is allowed, so there must be something else going on in my code. I’ll continue my tests.

Thanks again !

Cedric

Ok,

I’m gonna close this one because i solved the problem, though not understanding what i did.

The BP derived from my c++ controller class contained a cast to the bp derived from my c++ character class.

When both were called by the FObjectFinder from the same class, all was ok.

When they were called from different classes, the problem occured.

The casting was not done at construct time (only after some key was pressed during gametime).

When i suppressed the casting, the problem disappeared.

So, somehow, casting from a different owner seems to have created some sort of internal editor conflict.

Really not clear and i still don’t understand EU4 enough to try to understand.

Plus, i’ve already spent too much of unpleasant time with that so i close it.

Cedric