Download

UE 4.2 Custom character movement component now crashes editor

I have a custom ACharacter derived class, AMyChar, which also has a custom movement component UMyMovComp. The custom movement component overrides the default movement component as follows:



AMyChar::AMyChar(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP.SetDefaultSubobjectClass<UMyMovComp>(ACharacter::CharacterMovementComponentName))


Furthermore I have a blueprint, MyChar_BP, which inherits from AMyChar and 2 additional blueprints, MyChar_BP_A and MyChar_BP_B, which both inherit from MyChar_BP. When I click β€œPlay” in the editor it then crashes because the game dynamically creates new instances of MyChar_BP_A and MyChar_BP_B which will have a NULL movement component. During editor startup I will get the following error:


[2014.06.06-01.08.22:561]  0]LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyChar_BP_C'. There is another object (of 'MyMovComp' class) at the path.

This error is being logged at LinkerLoad.cpp line 3132 with the following stack trace:



UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::CreateExport(int Index) Line 3133	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::IndexToObject(FPackageIndex Index) Line 3363	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::operator<<(UObject * & Object) Line 3541	C++
UE4Editor-CoreUObject-Win64-Debug.dll!UObjectProperty::SerializeItem(FArchive & Ar, void * Value, int MaxReadBytes, const void * Defaults) Line 23	C++
UE4Editor-CoreUObject-Win64-Debug.dll!FPropertyTag::SerializeTaggedProperty(FArchive & Ar, UProperty * Property, unsigned char * Value, int MaxReadBytes, unsigned char * Defaults) Line 138	C++
UE4Editor-CoreUObject-Win64-Debug.dll!UStruct::SerializeTaggedProperties(FArchive & Ar, unsigned char * Data, UStruct * DefaultsStruct, unsigned char * Defaults) Line 1058	C++
UE4Editor-CoreUObject-Win64-Debug.dll!UClass::SerializeDefaultObject(UObject * Object, FArchive & Ar) Line 2994	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::Preload(UObject * Object) Line 2740	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::RegenerateBlueprintClass(UClass * LoadClass, UObject * ExportObject) Line 65	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::CreateExport(int Index) Line 3188	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::IndexToObject(FPackageIndex Index) Line 3363	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::operator<<(UObject * & Object) Line 3541	C++
UE4Editor-CoreUObject-Win64-Debug.dll!UClass::Serialize(FArchive & Ar) Line 2908	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::Preload(UObject * Object) Line 2746	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::CreateExport(int Index) Line 3234	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::IndexToObject(FPackageIndex Index) Line 3363	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::CreateExport(int Index) Line 3009	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::IndexToObject(FPackageIndex Index) Line 3363	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::CreateExport(int Index) Line 3009	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::CreateExportAndPreload(int ExportIndex, bool bForcePreload) Line 2426	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::LoadAllObjects(bool bForcePreload) Line 2501	C++
UE4Editor-CoreUObject-Win64-Debug.dll!LoadPackage(UPackage * InOuter, const wchar_t * InLongPackageName, unsigned int LoadFlags) Line 823	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::VerifyImportInner(const int ImportIndex, FString & WarningSuffix) Line 2142	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::VerifyImport(int i) Line 1940	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::VerifyImportInner(const int ImportIndex, FString & WarningSuffix) Line 2178	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::VerifyImport(int i) Line 1940	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::VerifyImportInner(const int ImportIndex, FString & WarningSuffix) Line 2178	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::VerifyImport(int i) Line 1940	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::Verify() Line 1727	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::FinalizeCreation() Line 1633	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::Tick(float InTimeLimit, bool bInUseTimeLimit, bool bInUseFullTimeLimit) Line 553	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ULinkerLoad::CreateLinker(UPackage * Parent, const wchar_t * Filename, unsigned int LoadFlags) Line 339	C++
UE4Editor-CoreUObject-Win64-Debug.dll!GetPackageLinker(UPackage * InOuter, const wchar_t * InLongPackageName, unsigned int LoadFlags, UPackageMap * Sandbox, FGuid * CompatibleGuid) Line 701	C++
UE4Editor-CoreUObject-Win64-Debug.dll!LoadPackage(UPackage * InOuter, const wchar_t * InLongPackageName, unsigned int LoadFlags) Line 784	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ResolveName(UObject * & InPackage, FString & InName, bool Create, bool Throw) Line 553	C++
UE4Editor-CoreUObject-Win64-Debug.dll!StaticLoadObject(UClass * ObjectClass, UObject * InOuter, const wchar_t * InName, const wchar_t * Filename, unsigned int LoadFlags, UPackageMap * Sandbox, bool bAllowObjectReconciliation) Line 655	C++
UE4Editor-MyUE4Game-Win64-Debug.dll!ConstructorHelpersInternal::FindOrLoadObject<UClass>(FString & PathName) Line 31	C++
UE4Editor-MyUE4Game-Win64-Debug.dll!ConstructorHelpers::FObjectFinder<UClass>::FObjectFinder<UClass>(const wchar_t * ObjectToFind) Line 91	C++
UE4Editor-MyUE4Game-Win64-Debug.dll!AMyGameMode::AMyGameMode(const FPostConstructInitializeProperties & PCIP) Line 17	C++
UE4Editor-MyUE4Game-Win64-Debug.dll!InternalConstructor<AMyGameMode>(const FPostConstructInitializeProperties & X) Line 2052	C++
UE4Editor-CoreUObject-Win64-Debug.dll!UClass::CreateDefaultObject() Line 2377	C++
UE4Editor-CoreUObject-Win64-Debug.dll!UObjectLoadAllCompiledInDefaultProperties() Line 507	C++
UE4Editor-CoreUObject-Win64-Debug.dll!ProcessNewlyLoadedUObjects() Line 576	C++
UE4Editor-CoreUObject-Win64-Debug.dll!TBaseStaticDelegateInstance_NoParams<void>::Execute() Line 812	C++
UE4Editor-CoreUObject-Win64-Debug.dll!TBaseStaticDelegateInstance_NoParams<void>::ExecuteIfSafe() Line 823	C++
UE4Editor-Core-Win64-Debug.dll!TBaseMulticastDelegate_NoParams<void>::Broadcast() Line 1815	C++
UE4Editor-Core-Win64-Debug.dll!FModuleManager::LoadModuleWithFailureReason(const FName InModuleName, ELoadModuleFailureReason::Type & OutFailureReason, const bool bWasReloaded) Line 379	C++
UE4Editor-Projects-Win64-Debug.dll!FProjectOrPlugin::LoadModules(const ELoadingPhase::Type LoadingPhase, TMap<FName,enum ELoadModuleFailureReason::Type,FDefaultSetAllocator,TDefaultMapKeyFuncs<FName,enum ELoadModuleFailureReason::Type,0> > & ModuleLoadErrors) Line 28	C++
UE4Editor-Projects-Win64-Debug.dll!FProjectManager::LoadModulesForProject(const ELoadingPhase::Type LoadingPhase) Line 86	C++
UE4Editor-Win64-Debug.exe!FEngineLoop::LoadStartupModules() Line 1723	C++
UE4Editor-Win64-Debug.exe!FEngineLoop::PreInit(const wchar_t * CmdLine) Line 1302	C++
UE4Editor-Win64-Debug.exe!EnginePreInit(const wchar_t * CmdLine) Line 32	C++
UE4Editor-Win64-Debug.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 111	C++
UE4Editor-Win64-Debug.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 196	C++


To summarize the classes for the 2 leaf blueprints, MyChar_BP_A and MyChar_BP_B, are being loaded in the constructor for AMyGameMode which causes ULinkerLoad::RegenerateBlueprintClass() to be called and ultimately results in the crash. The AMyGameMode constructor loads the classes as follows:



static ConstructorHelpers::FObjectFinder<UClass> team0BPClass(TEXT("Class'/Game/Blueprints/MyChar_BP_A.MyChar_BP_A_C'"));
static ConstructorHelpers::FObjectFinder<UClass> team1BPClass(TEXT("Class'/Game/Blueprints/MyChar_BP_B.MyChar_BP_B_C'"));

this->DefaultTeam0Class = team0BPClass.Object;
this->DefaultTeam1Class = team1BPClass.Object;


All of this worked fine in UE 4.1 so any help would be appreciated!

Very detailed post, and congrats on your first post!

Welcome to the forums Corrillian!

I hope Epic can get back to you on this one!

Rama

Here is a fix. Change LinkerLoad.cpp line 3130 from:



if (ActualObjectWithTheName && (ActualObjectWithTheName->GetClass() != LoadClass))
		{
			UE_LOG(LogLinker, Error, TEXT("Failed import: class '%s' name '%s' outer '%s'. There is another object (of '%s' class) at the path."),
				*LoadClass->GetName(), *Export.ObjectName.ToString(), *ThisParent->GetName(), *ActualObjectWithTheName->GetClass()->GetName());
			return NULL;
		}


To:



if (ActualObjectWithTheName && (ActualObjectWithTheName->GetClass() != LoadClass))
		{
			if(ActualObjectWithTheName->GetClass()->IsChildOf(LoadClass))
			{
				LoadClass = ActualObjectWithTheName->GetClass();
			}
			else
			{
				UE_LOG(LogLinker, Error, TEXT("Failed import: class '%s' name '%s' outer '%s'. There is another object (of '%s' class) at the path."),
					*LoadClass->GetName(), *Export.ObjectName.ToString(), *ThisParent->GetName(), *ActualObjectWithTheName->GetClass()->GetName());
				return NULL;
			}
		}


local var Template already points to the overridden component class so the rest of the code seems to just work.

Thx Corillian!

I had the same problem.

Some good guy (GeekyPayback) added commentary on wiki page https://wiki.unrealengine.com/Custom_Character_Movement_Component (see Addendum) stating that you need to recreate blueprint to avoid this error! It worked for me!

This issue is fixed in 4.3, so that my original wiki code works again :slight_smile:

Let me know if anyone has any issues still!

And thank you to whoever added the Addendum!

Rama