Download

Crash and unusable project after adding a UPROPERTY in a class

hi! i was learning some unreal stuff using a book called “Learning C++ by creating games with UE4”
ther is this chapter explaining the creation of an NPC using a Character class,
after creating the new class i need to add 2 properties:


UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Collision)
    TSubobjectPtr<class USphereComponent> ProxSphere;
and
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=NPCMessage)
   FString NpcMessage;

So, if i add only the FString and compile everything goes fine, if i add then the collision component it crashes on compiling and if i reopen the project it does not load at all and as i noticed it crashes al 70% project loading.

Here is the error showing on the crash report


MachineId:D996ACC2447CDC6263A55A8C0A1BCCE4
EpicAccountId:4051108148534ec5a319cfcb5693da72

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

"Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.8\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2318] 
ObjectProperty //Scrip

UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\misc\outputdevice.cpp:355]
UE4Editor_CoreUObject!FObjectInitializer::PostConstructInit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2318]
UE4Editor_CoreUObject!FObjectInitializer::~FObjectInitializer() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2182]
UE4Editor_CoreUObject!UClass::CreateDefaultObject() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\class.cpp:2591]
UE4Editor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:729]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:820]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:921]
UE4Editor_Core!TBaseMulticastDelegate<void>::Broadcast() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:1031]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\modules\modulemanager.cpp:431]
UE4Editor_Projects!FModuleDescriptor::LoadModulesForPhase() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\projects\private\moduledescriptor.cpp:370]
UE4Editor_Projects!FProjectManager::LoadModulesForProject() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\projects\private\projectmanager.cpp:52]
UE4Editor!FEngineLoop::LoadStartupModules() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\launchengineloop.cpp:1922]
UE4Editor!FEngineLoop::PreInit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\launchengineloop.cpp:1444]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\launch.cpp:110]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]


The book uses 4.4.3 i’m using 4.8.3 using Windows and VS Community version, i guess is a compatibility problem but as i’m learning UE4’s api starting from now i actually don’t know how to spot the problem.
Thanks :slight_smile:

Place quotes around the category name

Category=“Collision”
Category=“NPCMessage”

Dont know if it’ll resolve the crash, but in 4.8.3 you dont need wrap TSubObjectPtr around component variables anymore, so that can just be “class USphereComponent* ProxSphere;”

Ok so Illpill thanks for the tip, now the category ACTUALLY is showing. I’ll copythe project and check GalaxyMan2015’s tip, also i found on the documentation this type of spelling:


 // Our root component will be a sphere that reacts to physics
    USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));