2 classes breaking my program
I have a UE4 project that won't open in the past few days. It crashes on startup and I am unable to do anything in it. I'm desperate so here is my full, unaltered log. I have two classes, Starship and GameManager that are causing issues apparently, according to the log. In the definitions of the classes, the GENERATED_BODY() macro has "no storage class or type specifier" and the engine "cannot open" the generated headers, according to VS. However, none of my other classes have these issues. If there is anything else I can send for help, I'll gladly send it. This might be a UE4 issue, not sure. I have tried: compiling without any of my src in the source folder but still project outputs exact same log, deleting saved and intermediate, regenerating visual studio files, rebuilding, building, and cleaning. However, I duplicated my project through the library and IT DID OPEN TO THE EDITOR, but was in a mangled state with many assets missing.
asked Jul 03 '18 at 07:23 PM in Using UE4
First of all download debugging symbols (PDB) as i don't see engine call stack, you should have it in installation option in installed, they very useful inf you use C++ and it hard to debug without them. I only know your code is involved in crash as it shows in call stack (PDB for you code is generated when you compile it) more specificly constructors from your classes, engine also prints out the cause of it, so yes always look in logs when you get crash, solution is sometimes there:
Constructor of any UObject (this includes AActors which are also UObjects) class is called on module load on engine start up during creation of Class Default Object (CDO) which stores default values, this means if there something goes wrong in constructor the engine will on start up. Just by looking on call stack there something od in your costructor:
Call stack suggest that AGameManager costructor is calling AStarship costructor for some reason, like you trying to create AStarship inside AGameManager constrictor which is something that should not happen there. Due to nature of UObjects and UE4 reflection system, special use of constructors in UObject and mentioned CDO creation, constructors of UObject should not have any gameplay code and should only set default variables and/or set up components. Constructors are called in early initiation of the engine and object/actor it self and not everything is initiated during that point, which means most things you gonna try to do there most likely will crash, instead you should use events that UObjects and actors provide, it allows to inject code on most of most initiation steps some of them are described there:
PostInitializeComponents (runs also in editor) and BeginPlay (runs only in gameplay) are the safest spots as everything should work on that point.
Error message quated on top also suggest whatever you doing to create the actor you doing it wrong, actors should be only created with ActorSpawn and UObjects with NewObject and you should not do that in constructor because it gonna mess up CDO.
Thats all i could deduced from what you gave, for more you need to get those debug symbols and code snippets of both AStarship and AGameManager cpp and h files, aspecially constructors ofcorse
Follow this question
Once you sign in you will be able to subscribe for any updates here