C++ Game mode DefaultPawnClass selection issue

Hello,

I want to set my character in the GameMode.cpp file and I looked at the Unreal third person template for a reference. Here is how they do it:

ATestGameMode::ATestGameMode() {
	// set default pawn class to our Blueprinted character
	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter"));
	if (PlayerPawnBPClass.Class != NULL) 	{
		DefaultPawnClass = PlayerPawnBPClass.Class;
	}
}

Following this example, I did the same on my project:

AMyGameModeBase::AMyGameModeBase() {
	HUDClass = AMainHUD::StaticClass();
	
	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("Blueprint'/Game/Blueprints/CodeBlueprints/Characters/BP_Nagy.BP_Nagy_C'"));
/*
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("Blueprint'/Game/Blueprints/CodeBlueprints/Characters/BP_TestCharacter.BP_TestCharacter_C'"));
*/
	
	if (PlayerPawnBPClass.Class != NULL) {
		DefaultPawnClass = PlayerPawnBPClass.Class;
	}
}

This crashes will the following report:

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000990

UnrealEditor_TypedElementFramework!UTypedElementRegistry::GetMutableDataStorageCompatibility() [D:\build\++UE5\Sync\Engine\Source\Runtime\TypedElementFramework\Private\Elements\Framework\TypedElementRegistry.cpp:84]
UnrealEditor_Engine!UEngineElementsLibrary::CreateActorElement() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Elements\Framework\EngineElementsLibrary.cpp:363]
UnrealEditor_Engine!UE::Core::Private::Function::TFunctionRefCaller<TTypedElementOwner<FActorElementData> (__cdecl*)(AActor const *),TTypedElementOwner<FActorElementData> __cdecl(AActor const *)>::Call() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Templates\Function.h:470]
UnrealEditor_Engine!UEngineElementsLibrary::CreateEditorActorElement() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Elements\Framework\EngineElementsLibrary.cpp:403]
UnrealEditor_Engine!AActor::PostInitProperties() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:404]
UnrealEditor_CoreUObject!FObjectInitializer::PostConstructInit() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:3919]
UnrealEditor_CoreUObject!FObjectInitializer::~FObjectInitializer() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:3749]
UnrealEditor_CoreUObject!StaticConstructObject_Internal() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:4389]
UnrealEditor_UnrealEd!ReplaceObjectHelper() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Kismet2\KismetReinstanceUtilities.cpp:2016]
UnrealEditor_UnrealEd!FBlueprintCompileReinstancer::ReplaceInstancesOfClass_Inner() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Kismet2\KismetReinstanceUtilities.cpp:2617]
UnrealEditor_UnrealEd!FBlueprintCompileReinstancer::BatchReplaceInstancesOfClass() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Kismet2\KismetReinstanceUtilities.cpp:1671]
UnrealEditor_Kismet!FBlueprintCompilationManagerImpl::FlushReinstancingQueueImpl() [D:\build\++UE5\Sync\Engine\Source\Editor\Kismet\Private\BlueprintCompilationManager.cpp:1934]
UnrealEditor_CoreUObject!EndLoad() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2328]
UnrealEditor_CoreUObject!`LoadPackageInternal'::`102'::<lambda_2>::operator()() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1751]
UnrealEditor_CoreUObject!LoadPackageInternal() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1785]
UnrealEditor_CoreUObject!LoadPackage() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2014]
UnrealEditor_CoreUObject!LoadPackage() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1987]
UnrealEditor_CoreUObject!ResolveName() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1192]
UnrealEditor_CoreUObject!StaticLoadObjectInternal() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1302]
UnrealEditor_CoreUObject!StaticLoadObject() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1377]
UnrealEditor_CoreUObject!StaticLoadClass() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1410]
UnrealEditor_MDVProject2!ConstructorHelpersInternal::FindOrLoadClass() [C:\Program Files\Epic Games\UE_5.3\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h:68]
UnrealEditor_MDVProject2!AMyGameModeBase::AMyGameModeBase() [C:\Users\usuario\OneDrive\Documents\Unreal Projects\MDV\Project2\MDVProject2_Playable\Source\MDVProject2\GameMode\MyGameModeBase.cpp:15]
UnrealEditor_CoreUObject!UClass::CreateDefaultObject() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:4390]
UnrealEditor_CoreUObject!UClass::InternalCreateDefaultObjectWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:4987]
UnrealEditor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:825]
UnrealEditor_CoreUObject!ProcessNewlyLoadedUObjects() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:909]
UnrealEditor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:777]
UnrealEditor_Core!TMulticastDelegate<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::Broadcast() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:956]
UnrealEditor_Core!FModuleManager::LoadModuleWithFailureReason() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Modules\ModuleManager.cpp:624]
UnrealEditor_Projects!FModuleDescriptor::LoadModulesForPhase() [D:\build\++UE5\Sync\Engine\Source\Runtime\Projects\Private\ModuleDescriptor.cpp:696]
UnrealEditor_Projects!FProjectManager::LoadModulesForProject() [D:\build\++UE5\Sync\Engine\Source\Runtime\Projects\Private\ProjectManager.cpp:62]
UnrealEditor!FEngineLoop::LoadStartupModules() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4671]
UnrealEditor!FEngineLoop::PreInitPostStartupScreen() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:3942]
UnrealEditor!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:140]
UnrealEditor!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:118]
UnrealEditor!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:258]
UnrealEditor!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:298]
UnrealEditor!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

Rider’s Unreal link console shows a somewhat different error:

Error        LogOutputDevice           === Handled ensure: ===
Error        LogOutputDevice           Ensure condition failed: Registry  [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Elements\Framework\EngineElementsLibrary.cpp] [Line: 33] 
Error        LogOutputDevice           Typed element was requested for '/Engine/Transient.Default__BP_Nagy_C:DashBP.DashBP_BP_Niagara_Replay_C_CAT' before the registry was available! This usually means that NewObject was used instead of CreateDefaultSubobject during CDO construction.
Error        LogOutputDevice           Stack: 
Error        LogOutputDevice           [Callstack] 0x00007ff855b7458d UnrealEditor-Engine.dll!UEngineElementsLibrary::CreateActorElement() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Elements\Framework\EngineElementsLibrary.cpp:357]
Error        LogOutputDevice           [Callstack] 0x00007ff855b68f51 UnrealEditor-Engine.dll!UE::Core::Private::Function::TFunctionRefCaller<TTypedElementOwner<FActorElementData> (__cdecl*)(AActor const *),TTypedElementOwner<FActorElementData> __cdecl(AActor const *)>::Call() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Templates\Function.h:470]
Error        LogOutputDevice           [Callstack] 0x00007ff855b75ab9 UnrealEditor-Engine.dll!UEngineElementsLibrary::CreateEditorActorElement() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Elements\Framework\EngineElementsLibrary.cpp:403]
Error        LogOutputDevice           [Callstack] 0x00007ff854f573f7 UnrealEditor-Engine.dll!AActor::PostInitProperties() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:404]
Error        LogOutputDevice           [Callstack] 0x00007ff86aab385e UnrealEditor-CoreUObject.dll!FObjectInitializer::PostConstructInit() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:3919]
Error        LogOutputDevice           [Callstack] 0x00007ff86aa7f9cd UnrealEditor-CoreUObject.dll!FObjectInitializer::~FObjectInitializer() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:3749]
Error        LogOutputDevice           [Callstack] 0x00007ff86aac7f37 UnrealEditor-CoreUObject.dll!StaticConstructObject_Internal() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:4389]
Error        LogOutputDevice           [Callstack] 0x00007ff8536f26ee UnrealEditor-UnrealEd.dll!ReplaceObjectHelper() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Kismet2\KismetReinstanceUtilities.cpp:2016]
Error        LogOutputDevice           [Callstack] 0x00007ff8536efe24 UnrealEditor-UnrealEd.dll!FBlueprintCompileReinstancer::ReplaceInstancesOfClass_Inner() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Kismet2\KismetReinstanceUtilities.cpp:2617]
Error        LogOutputDevice           [Callstack] 0x00007ff853699856 UnrealEditor-UnrealEd.dll!FBlueprintCompileReinstancer::BatchReplaceInstancesOfClass() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Kismet2\KismetReinstanceUtilities.cpp:1671]
Error        LogOutputDevice           [Callstack] 0x00007ff8507fe08c UnrealEditor-Kismet.dll!FBlueprintCompilationManagerImpl::FlushReinstancingQueueImpl() [D:\build\++UE5\Sync\Engine\Source\Editor\Kismet\Private\BlueprintCompilationManager.cpp:1934]
Error        LogOutputDevice           [Callstack] 0x00007ff86aa99331 UnrealEditor-CoreUObject.dll!EndLoad() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2328]
Error        LogOutputDevice           [Callstack] 0x00007ff86aa827e2 UnrealEditor-CoreUObject.dll!`LoadPackageInternal'::`102'::<lambda_2>::operator()() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1751]
Error        LogOutputDevice           [Callstack] 0x00007ff86aaad225 UnrealEditor-CoreUObject.dll!LoadPackageInternal() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1785]
Error        LogOutputDevice           [Callstack] 0x00007ff86aaab918 UnrealEditor-CoreUObject.dll!LoadPackage() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2014]
Error        LogOutputDevice           [Callstack] 0x00007ff86aaabeb6 UnrealEditor-CoreUObject.dll!LoadPackage() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1987]
Error        LogOutputDevice           [Callstack] 0x00007ff86aac16a1 UnrealEditor-CoreUObject.dll!ResolveName() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1192]
Error        LogOutputDevice           [Callstack] 0x00007ff86aad228c UnrealEditor-CoreUObject.dll!StaticLoadObjectInternal() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1302]
Error        LogOutputDevice           [Callstack] 0x00007ff86aad18e0 UnrealEditor-CoreUObject.dll!StaticLoadObject() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1377]
Error        LogOutputDevice           [Callstack] 0x00007ff86aad0ff5 UnrealEditor-CoreUObject.dll!StaticLoadClass() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1410]
Error        LogOutputDevice           [Callstack] 0x00007ff82b0e0a3a UnrealEditor-MDVProject2.dll!ConstructorHelpersInternal::FindOrLoadClass() [C:\Program Files\Epic Games\UE_5.3\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h:68]
Error        LogOutputDevice           [Callstack] 0x00007ff82b0e06ef UnrealEditor-MDVProject2.dll!AMyGameModeBase::AMyGameModeBase() [C:\Users\usuario\OneDrive\Documents\Unreal Projects\MDV\Project2\MDVProject2_Playable\Source\MDVProject2\GameMode\MyGameModeBase.cpp:15]
Error        LogOutputDevice           [Callstack] 0x00007ff86a6fd412 UnrealEditor-CoreUObject.dll!UClass::CreateDefaultObject() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:4390]
Error        LogOutputDevice           [Callstack] 0x00007ff86a71d163 UnrealEditor-CoreUObject.dll!UClass::InternalCreateDefaultObjectWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:4987]
Error        LogOutputDevice           [Callstack] 0x00007ff86aa4e9d9 UnrealEditor-CoreUObject.dll!UObjectLoadAllCompiledInDefaultProperties() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:825]
Error        LogOutputDevice           [Callstack] 0x00007ff86aa2b410 UnrealEditor-CoreUObject.dll!ProcessNewlyLoadedUObjects() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:909]
Error        LogOutputDevice           [Callstack] 0x00007ff86a8dabc5 UnrealEditor-CoreUObject.dll!TBaseStaticDelegateInstance<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:777]
Error        LogOutputDevice           [Callstack] 0x00007ff8691e9163 UnrealEditor-Core.dll!TMulticastDelegate<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::Broadcast() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:956]
Error        LogOutputDevice           [Callstack] 0x00007ff86921584b UnrealEditor-Core.dll!FModuleManager::LoadModuleWithFailureReason() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Modules\ModuleManager.cpp:624]
Error        LogOutputDevice           [Callstack] 0x00007ff88b3987ee UnrealEditor-Projects.dll!FModuleDescriptor::LoadModulesForPhase() [D:\build\++UE5\Sync\Engine\Source\Runtime\Projects\Private\ModuleDescriptor.cpp:696]
Error        LogOutputDevice           [Callstack] 0x00007ff88b398c12 UnrealEditor-Projects.dll!FProjectManager::LoadModulesForProject() [D:\build\++UE5\Sync\Engine\Source\Runtime\Projects\Private\ProjectManager.cpp:62]
Error        LogOutputDevice           [Callstack] 0x00007ff7143624dc UnrealEditor.exe!FEngineLoop::LoadStartupModules() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4671]
Error        LogOutputDevice           [Callstack] 0x00007ff71436634f UnrealEditor.exe!FEngineLoop::PreInitPostStartupScreen() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:3942]
Error        LogOutputDevice           [Callstack] 0x00007ff71435cfb6 UnrealEditor.exe!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:140]
Error        LogOutputDevice           [Callstack] 0x00007ff71435d37a UnrealEditor.exe!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:118]
Error        LogOutputDevice           [Callstack] 0x00007ff714360854 UnrealEditor.exe!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:258]
Error        LogOutputDevice           [Callstack] 0x00007ff714376984 UnrealEditor.exe!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:298]
Error        LogOutputDevice           [Callstack] 0x00007ff714379d7a UnrealEditor.exe!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
Error        LogOutputDevice           [Callstack] 0x00007ff8dc237344 KERNEL32.DLL!UnknownFunction []
Error        LogOutputDevice           [Callstack] 0x00007ff8dde826b1 ntdll.dll!UnknownFunction []

To debug this I copied the third person character class to my project (cpp & .h), I then gradually started changing the code from the third person character to mine until it’s literally the same code line by line, yet this imported third character works but not mine. So I have now to characters that are (codewise) exactly the same and one works and the other one crashes.

I’m at a loss and I have no idea what I should be looking for to understand what is happening. Why does this happen? How can I make my character work?

NOTE:
My modified third person character path works with:

  • “Blueprint’/Game/Blueprints/CodeBlueprints/Characters/BP_TestCharacter.BP_TestCharacter_C’”
  • “/Game/Blueprints/CodeBlueprints/Characters/BP_TestCharacter.BP_TestCharacter_C”
  • “/Script/Engine.Blueprint’/Game/Blueprints/CodeBlueprints/Characters/BP_TestCharacter.BP_TestCharacter_C’”

The object type declarator at the beginning seems to be irrelevant, what I found necessary was to add _C at the end, which is something the template does not have but if I don’t add it, the project loads but the character selected is the default one.

try

	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/Blueprints/CodeBlueprints/Characters/BP_Nagy"));
	if (PlayerPawnBPClass.Class != NULL)
	{
		DefaultPawnClass = PlayerPawnBPClass.Class;
	}

You use the _C extension for the blueprint name when trying to access FSoftObjectPath’s

edit

are you using NewObject to instantiate DashBP_BP_Niagara_Replay_C_CAT inside of the constructor? If so that’s bad.

NewObject should only be used once the world exists → so during begin play and after. You need the world to spawn in a new object.
For object components use CreateDefaultSubObject(TEXT(“name of component”))
inside of the CDO

Thanks for the suggestion. I tried using the line you suggested and it crashes as it did before.

Regarding the Dash_BP, this is a component in the main character. It’s created in the constructor and I do it by calling CreateDefaultSubobject (the function InitComponents is called in the contructor, I just put the component creation on a separate function for clarity).

If you look at the image, you can see that the only instances of DashChildBP in my project exist in the constructor of both Nagy (which is the one that crashes) and TestCharacter (which works fine).

They both have the exact same code as TestCharacter is a copy paste of the entirety of Nagy.

When the user presses space bar, the space bar input action function is called in cpp which contains a BlueprintImplementableEvent called TriggerNiagaraDashEffect(). This is implemented in BP and again, both Nagy and TestCharacter have the same implementation as one is a copy of the other. Adding picture of this too.

This is my real problem, I don’t know how to debug a character that works and another that does not if their code and BP are exactly the same.

Does this other character inherit from the class? Perhaps you are missing a call to initialize the components in the parent class (a super call)

They both inherit from ACharacter. I just made a push to my repo, you can see the code for Nagy and TestCharacter there.

Also, if I set the game mode with BP and select the Nagy BP, it works fine. All components initialise correctly and you can play without issues. I’m trying to do the same with CPP but it refuses to work.

I could delete Nagy, rename TestCharacter and just keep working, but I want to learn what is happening here as there must be something I’m missing.

Tried the c++ source but all of the hard coded links to blueprints causes it to not generate. After commenting out most hard codes it unfortunately crashes at the 75% mark.

Wouldn’t it be more flexible to just expose a TSubClassOf Uproperty to give yourself more flexibility? Was never a fan of hardcoded loading unless you are loading a soft path to an actor with async loading.

Try maybe launching fix up redirects in your content and blueprint folder with the character. Perhaps you moved a file that the engine lost track of and it’s path is no longer valid.

I believe I figured it out.

Yesterday I fixed the redirectors as you said and the result was the same, crash at the 75% mark.

I then went ahead and commented the DashChildBP declaration from the .h and its initialisation from the .cpp. With this Nagy was working. I then went to Rider and navigated to Build > Rebuild solution. Once this was done, I uncommented those lines and Nagy was working but it did not trigger the Dash niagara particles.

When I took a look at the BP, I noticed that the DashChildBP Child Actor Class field was empty. When I set this field to the BP_Niagara_Replay, the issue occurred so that was the culprit. The TestCharacter was working because when I duplicated the code from Nagy, I copied too the anim blueprint and other stuff, but this was the only thing I forgot to add, if I had given it the BP_Niagara_Replay, it would have crashed too.

Note that the BP_Niagara_Replay is an external bundle and that I have no idea how it’s implemented. Perhaps it does indeed use the NewObject instead of the CreateDefaultSubobject as the log said. This or for some reason the Nagy BP was being created before the BP_Niagara_Replay and thus it did not exist when it required it (?).

In any case, I’m happy I figured it out. I believe I will just get rid of this child actor as I only use it to trigger a Niagara effect and I can do that without the need for a child actor.

Thank you for the support @3dRaven, I sort of used you as debug duck but it worked so your input has been much appreciated.


EDIT:

Quick follow up as I did a test:

Worked correctly:

static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Script/Engine.Blueprint'/Game/Blueprints/CodeBlueprints/Characters/BP_Nagy.BP_Nagy_C'"));
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("Blueprint'/Game/Blueprints/CodeBlueprints/Characters/BP_Nagy.BP_Nagy_C'"));
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/Blueprints/CodeBlueprints/Characters/BP_Nagy"));

NOT working:

static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Script/Engine.Blueprint'/Game/Blueprints/CodeBlueprints/Characters/BP_Nagy.BP_Nagy'"));
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("Blueprint'/Game/Blueprints/CodeBlueprints/Characters/BP_Nagy.BP_Nagy'"));
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/Blueprints/CodeBlueprints/Characters/BP_Nagy_C"));

From this I take that if you precede it with a Blueprint specifier, you need to add the _C to let it know that you want the class, but if you don’t add the Blueprint specifier then the _C is incorrect.

You could try pushing DashChildBP’s initialization to begin play with a NewObject operation, then maybe the order of operation will be in the same league as the niagara component.

But you would need to register the component manually.

1 Like

That’s a good idea too, though it’s just declaring the niagara effect with extra steps. What I require from the aforementioned package is the niagara effects, the Blueprint they came with is not required and as I have learned here, using other people’s code can lead to issues.