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.