Crash while using extended CharacterMovementComponent

I posted this problem on the forums, but I realize it’s probably more appropriate to have it here.

I’m attempting to extend the default CharacterMovementComponent. I used the tutorial written by Rama here.

My code is as follows (using the default TopDown level as a base - and 4.7.3):

MyProjectCharacterMovementComponent.h

UCLASS()
class UMyProjectCharacterMovementComponent : public UCharacterMovementComponent
{
	GENERATED_BODY()
};

MyProjectCharacterMovementComponent.cpp

//Nothing yet

MyProjectCharacter.cpp (The only change is adding the SetDefaultSubobjectClass line to the original code)

AMyProjectCharacter::AMyProjectCharacter(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer.SetDefaultSubobjectClass<UMyProjectCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))
{
...

And here’s the error I get.

Unknown exception - code 00000001 (first/second chance not available)

Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.7\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 1644] 
Object is not packaged: None None

KERNELBASE + 37901 bytes
UE4Editor_Core!FOutputDeviceWindowsError::Serialize() + 292 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:95]
UE4Editor_Core!FMsg::Logf__VA() + 463 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\misc\outputdevice.cpp:526]
UE4Editor_CoreUObject!StaticAllocateObjectErrorTests() + 941 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:1644]
UE4Editor_CoreUObject!StaticAllocateObject() + 197 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:1693]
UE4Editor_CoreUObject!UClass::CreateDefaultObject() + 319 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\class.cpp:2502]
UE4Editor_CoreUObject!FObjectInitializer::CreateDefaultSubobject() + 569 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2649]
UE4Editor_CoreUObject!UObject::CreateDefaultSubobject() + 419 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\obj.cpp:62]
UE4Editor_Engine!ACharacter::ACharacter() + 888 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\character.cpp:77]
UE4Editor_MyProject_3972_Win64_DebugGame!AMyProjectCharacter::AMyProjectCharacter() + 117 bytes [e:\unreal projects\game1\myproject\source\myproject\myprojectcharacter.cpp:10]
UE4Editor_MyProject_3972_Win64_DebugGame!AMyProjectCharacter::__DefaultConstructor() + 76 bytes [e:\unreal projects\game1\myproject\source\myproject\myprojectcharacter.h:9]
UE4Editor_MyProject_3972_Win64_DebugGame!InternalConstructor<AMyProjectCharacter>() + 40 bytes [e:\unreal engine\epic games\4.7\engine\source\runtime\coreuobject\public\uobject\class.h:2238]
UE4Editor_CoreUObject!StaticConstructObject() + 1444 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2237]
UE4Editor_CoreUObject!UClass::HotReloadPrivateStaticClass() + 397 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\class.cpp:3368]
UE4Editor_MyProject_3972_Win64_DebugGame!GetPrivateStaticClassBody<AMyProjectCharacter>() + 526 bytes [e:\unreal engine\epic games\4.7\engine\source\runtime\coreuobject\public\uobject\class.h:2279]
UE4Editor_MyProject_3972_Win64_DebugGame!AMyProjectCharacter::GetPrivateStaticClass() + 78 bytes [e:\unreal projects\game1\myproject\intermediate\build\win64\inc\myproject\myproject.generated.cpp:50]
UE4Editor_MyProject_3972_Win64_DebugGame!TClassCompiledInDefer<AMyProjectCharacter>::Register() + 42 bytes [e:\unreal engine\epic games\4.7\engine\source\runtime\coreuobject\public\uobject\uobjectbase.h:296]
UE4Editor_CoreUObject!UClassRegisterAllCompiledInClasses() + 176 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:690]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() + 11 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:808]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() + 7 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:921]
UE4Editor_Core!TBaseMulticastDelegate<void>::Broadcast() + 149 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:1030]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() + 2194 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\modules\modulemanager.cpp:359]
UE4Editor_Core!FModuleManager::LoadModule() + 56 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\modules\modulemanager.cpp:238]
UE4Editor_HotReload!FHotReloadModule::DoHotReloadInternal() + 648 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\developer\hotreload\private\hotreload.cpp:654]
UE4Editor_HotReload!FHotReloadModule::DoHotReloadFromIDE() + 1660 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\developer\hotreload\private\hotreload.cpp:1059]
UE4Editor_HotReload!FHotReloadModule::Tick() + 112 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\developer\hotreload\private\hotreload.cpp:995]
UE4Editor!FTicker::Tick() + 698 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\public\containers\ticker.h:90]
UE4Editor!FEngineLoop::Tick() + 6356 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launchengineloop.cpp:2352]
UE4Editor!GuardedMain() + 1404 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]

The error occurs during hot reload. However, restarting the editor doesn’t see to load in the extended CharacterMovementComponent either. Any help would be appreciated.

I think you just need to add the constructor for you character movement class, otherwise the Engine has no idea how to create the object that it needs to attach.

Okay, I added the following constructor to the movement class:

UMyProjectCharacterMovementComponent(const class FPostConstructInitializeProperties& PCIP)
		: Super(PCIP)
	{

	}

I now get the following error on hot reload:

Unknown exception - code 00000001 (first/second chance not available)

Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.7\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 1737] 
Objects have the same fully qualified name but different paths.
	New Object: MyProjectChara

KERNELBASE + 37901 bytes
UE4Editor_Core!FOutputDeviceWindowsError::Serialize() + 292 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:95]
UE4Editor_Core!FMsg::Logf__VA() + 463 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\misc\outputdevice.cpp:526]
UE4Editor_CoreUObject!StaticAllocateObject() + 1087 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:1737]
UE4Editor_CoreUObject!StaticConstructObject() + 785 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2231]
UE4Editor_CoreUObject!FObjectInitializer::CreateDefaultSubobject() + 630 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2651]
UE4Editor_CoreUObject!UObject::CreateDefaultSubobject() + 419 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\obj.cpp:62]

Is my syntax for the constructor correct?

Edit: Deleting the old blueprints that used MyProjectCharacter and hot reloading gave me the original error again.

It should be UMyProjectCharacterMovementComponent::UMyProjectCharacterMovementComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {}

Okay, I switched to that syntax, but I still get the same error (The one on line 1644)

I tried to reproduce your error but couldn’t do it.

Here’s what I did:

  1. Created a new C++ Third Person Template project.
  2. Added Code to class with base class UCharacterMovementComponent.
  3. Closed my editor.
  4. Added the MyMovementComponent.h to my MyCharacter.cpp
  5. In my character’s constructor, changed the default movement component to use my custom class.
  6. Compiled the code and launched the editor. The Movement Component was correctly using my custom class.

Okay, recreating the project seems to have worked! Though, it’s a bit unnerving to have the threat of fatal and unforeseen errors looming overhead, heh

For the time being, this seems to be working! Thanks for the help!

I’m still getting a (non-fatal) error when I reopen the project. I get a nice big red:

LoadErrors:Error: Error Failed import for MonsterGameCharacterMovementComponent

In the output log.

In the message log, I get:

Error Failed import for MonsterGameCharacterMovementComponent /Game/TopDown/Blueprints/TopDownCharacter.Default__TopDownCharacter_C:CharMoveComp

So, it seems like a blueprint issue?

Hot reloading works fine, however. Is there a way to debug this error? (As it is I have to hot reload the editor to update the code)

Edit: It seems like explicitly saving the blueprint with the extend code in it fixed the problem? There’s gotta be a better way, though.