UE4 crashes when I want to open my project

Hello. I think this is the 5th time I am getting this crash in 2 days. I deleted and created new project of the same project and had to redesign them from the beggining of the project. Even though I undo all the changes I have made of my project (In visual studio), to the condutions when it works just fine, it still crashes. Any help would be appreciated. Thanks in advance. Take care!

Project Name: Roguelike
The thinks I have done before the crash:

I added a new variable APlayerCharacter* MainCharacter in my enemy class

I tried to get the player instance in my enemy class’ constructor

I tried to add an AddOnScreenDebugMessage for checking if I could get the mainplayer’s name

I changed EngineMinimal.h to Engine.h in Roguelike.h

Here is my crash report:

Assertion failed: Object [File:D:\BuildFarm\buildmachine_++UE4+Release-4.11\Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp] [Line: 8022] 



UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\private\misc\outputdevice.cpp:430]
UE4Editor_Engine!UEngine::GetWorldFromContextObject() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\unrealengine.cpp:8024]
UE4Editor_Engine!UGameplayStatics::GetPlayerController() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\gameplaystatics.cpp:45]
UE4Editor_Engine!UGameplayStatics::GetPlayerCharacter() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\engine\private\gameplaystatics.cpp:64]
UE4Editor_Roguelike!AEnemyCharacter::AEnemyCharacter() [c:\users\emreb\documents\unreal projects\roguelike\source\roguelike\enemycharacter.cpp:14]
UE4Editor_CoreUObject!UClass::CreateDefaultObject() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\class.cpp:2763]
UE4Editor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:724]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:818]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance::ExecuteIfSafe() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:1021]
UE4Editor_Core!TBaseMulticastDelegate::Broadcast() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:921]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\core\private\modules\modulemanager.cpp:427]
UE4Editor_Projects!FModuleDescriptor::LoadModulesForPhase() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\projects\private\moduledescriptor.cpp:398]
UE4Editor_Projects!FProjectManager::LoadModulesForProject() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\projects\private\projectmanager.cpp:53]
UE4Editor!FEngineLoop::LoadStartupModules() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\launchengineloop.cpp:2081]
UE4Editor!FEngineLoop::PreInit() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\launchengineloop.cpp:1544]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\launch.cpp:110]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll

Hey emrebaris-

Can you provide the code you used? Specifically, what class is your Enemy class based on and what code are you using to get the player instance? Can you try moving the “get player instance” code from the constructor to the BeginPlay() function and let me know if the crash still occurs.

Hello .
Sure I can provide you my code but unfortunately I have the code before I got crash, the one I’ve undone every change I’ve made.

However, I just made a new project, named Roguelike again, and I replaced my new Roguelike project’s content and source files with the old ones and I could open the editor.

Here’s my codes if they are handy:

link text
link text

Based on the callstack, the crash appears to be from attempting to access information before it has been set. The call inside your constructor seems to make an eventual call to GetWorld(). If your project was crashing when attempting to open the project then this would make sense as the world does not exist yet. You can guard against this by doing if(GetWorld()) to check if the world is valid prior to using it. Additionally, moving the code that calls GetWorld to the begin play function should solve the issue.

Cheers