I’ve been a few days trying to work on a C++ project in Unreal and I’ve had the same issue on two different projects. Both times I’ve created my classes, built the project with no errors and been able to hit Play with the objects in the level, but when I’ve added a breakpoint and tried to debug from Visual Studio the project crashes and won’t let me open it again. Whenever I try “The following process has crashed” window appears. I’ve already sent the logs, but I attach the whole file to this message.
Could you share one of these projects that is crashing for you or at least the source that they contain? Where are you placing these breakpoints? From the callstack itself and the errors given, it seems like an issue related to the constructor or trying to do something outside of the constructor which can only be done within. The particular message I’m talking about is this one:
UObject(const FObjectInitializer&) constructor called but it’s not the object that’s currently being constructed with NewObject. Maybe you trying to construct it on the stack which is not supported.
Sure. Thanks for your reply!
I was trying to check why this wasn’t working:
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, “Hi”);
Thank you for providing the project. I wish the error message was more clear but it at least gave me an idea of where to look. The reason for the crash is due to you trying to create an instance of the UPlotGraph as a member of PlotGenerator. Instead of doing this, you need to create a pointer to a reference of one. On line #24 in PlotGenerator.h, add a * after the class name. In the constructor for APlotGenerator in the PlotGenerator.cpp, add something along the lines of this to initialize the pointer:
attackPlot = CreateDefaultSubobject<UPlotGraph>(TEXT("attackPlot"));
Hope this helps!
Thanks, I am new to C++ in Unreal. I’ve added your suggested changes and the project builds fine from Visual Studio, but it still crashes when I try to open it in Unreal. It doesn’t make sense to me that the whole engine should crash due to an error in the code, but is there a way to “restore” my project?
Nevermind, removed the #include “PlotGraph.h” and recovered my project.