Player Controller Blueprint crashes editor when accessed

I have created custom classes for both “Player Controller” and “Character” in C++. At first I did not have any problems and was able to create the blueprint for both, then run them in my scene. Recently, however, I noticed that when I try to access the Player Controller BP (which inherits from my custom Player Controller script), the editor crashes even though my source code compiles with no errors or warnings. Upon the first crash, I got feedback suggesting that I was calling ()->GetFirstPlayerController()->GetPlayerViewPoint and this was causing a problem (I have references to my custom Character class in my Controller and perhaps this was causing a circular dependency of some sort). I removed that line and now the editor crashes, but with no useful warnings whatsoever. Anyone know why this could be? Any help is highly appreciated! I just noticed I am also getting the log warning "Couldn’t goto line number ‘0’ in ‘…/NewPlayerController.h’

“the editor crashes even though my source code compiles with no errors or warnings.” Fact that something compiled give 0 guaranty it won’t crash. Compiler will only give you errors and warnings to things that cause problems in generation and linking of machine code (code that your CPU run), but it can’t won’t predict runtime errors, it assumes you know what you doing in logic of your code and assumes your code will predict any problems to prevent crashes. Even higher languages with more supervise nature won’t give you all possible error on compile time as it simply can’t predict all potential problems that can happen in runtime and can crash application due to unhandled exception (Java in Android case) aka error exception that your code don’t handle.

If crash happens first thing you need to do is check log, in Saved/Logs of your project directory. UE4 have assertion system (Assertion (software development) - Wikipedia) which detect potential unpredictable instabilities which can cause crash by asserting correct states of things before executing preticilar function. If assertion fails, UE4 crash it self with error log, showing expected condition (a bool, same as “if” statement) that returned false and point where it happen in code and show the stack. Majority of those assertion checks are not descriptive give out only failed condition so it sometimes requires some investigative work, sometimes they pretty obviues, some have error messages even explaining what you should do.

If you see log cut that means unpredicted crash happened, error occurred direcly in machine code execution managed by OS and system cut out UE4 without even notifying it to prevent crash of entire system. Number one cause of this is calling function on null and invalid memory pointers (memory pointers are varables with * in type, all object varables with UObject are pointers) or invalid casting, which causes memory access errors. In this case you should run debug and cause that crash and VS debugger will show you where crash occured in the code. Code you gived ()->GetFirstPlayerController()->GetPlayerViewPoint can potentially crash UE4 this way if () return null ponter which can mean that world is not initiated or actor it self is not fully initiated and don’t have world assigned, GetFirstPlayerController() return null if there is no any player controller initiated, in most cases it is calling those functions in too early stages of initiation either actor or a world. So check where do you call those functions. Before calling functions on other functions that may return null pointer, check if they return null before calling to prevent crash.

If you want any ferther help you need to explain your code where do you call that function that you mention, whats appeing in logs etc. otherwise people can only guess whats going on

With UE4 it’s impotent to understand that your C++ code is a extension of the engine it becomes part of it, you just making extra module to it, one of many already existing in engine code and plugins. Modules (dll files in binary directory) work same way regardless where they are. If something goes wrong in your code the entire engine and editor that runs on top of it goes with it. So makes sure your code works correcly and cooperates with rest of the engine. Don’t be afraid to explore engine code to see what engine doing when you call perticilar function you cna learn a lot by doing so. Again your code becomes part of engine so you should know what engine code behaves.