Unreal Engine crashes every time I try to open my project, even after I've commented out this line

I’ve run into an issue before where some code I’ve written in my project somehow crashes Unreal out of nowhere. However, I wrote this code a while ago without issue, and even after I’ve commented out the line that apparently triggers the crash, I cannot open my project.

Can anyone parse this junk message and give me direction on how to recover my old project?

@anonymous_user_0a83f5f8 Happy You =

  1. Move all of your debug code out of your C++ Constructor and into BeginPlay()

  2. Don’t use pointers, even to your own components, without checking them first, especially in a C++ constructor

  3. Probably one of the components, whose pointer you are not checking, got deleted or is not getting properly constructed for some reason, yet you are trying to access it in the C++ constructor, without checking the pointer first.

if(ThirdPersonCameraComponent != nullptr)
{
    FVector CamPos = ThirdPersonCameraComponent->GetComponentLocation();
}

If you don’t check every pointer :boom:

You won’t get to Game Release

If you check every pointer, :rainbow:

You will be the one writing these words to someone else!

Always Check Your Pointers!

:heart:

Rama

PS: You also should check your GEngine pointer, it is good practice, especially in a C++ Constructor (the most unstable place to be writing code btw) and better yet, don’t try to use GEngine in a C++ Constructor at all, all your code moved → to BeginPlay = no more problems if you also check every pointer.

PSS: Checking your pointers is :star2: free :star2: compared to being stuck and having to wait for someone to tell you to :rose: :zap: check your pointers :zap: :rose:

Thank you for that. However, I do have these statements at lines 13 and 14, which weren’t included in the screenshot.

ThirdPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("ThirdPersonCamera"));
	check(ThirdPersonCameraComponent != nullptr);

Your advice is duly noted, however.

Are you suggesting I do this before attempting the on-screen debug message?
check(GEngine != nullptr);

What’s more is that I can’t even be sure that the line in the crash report is correct at all. No matter how I change the code, the project always crashes. Is there a way to recompile the code without launching Unreal? That might help.

Have you tried moving all of your logics out of your C++ constructor, and checking all pointers of anything left?

I would try to remove all fancy logics of any kind from C++ constructor and move them into BeginPlay(), until there’s almost nothing left in C++ constructor

Systematic removal of stuff from C++ Constructor will get you closer and closer to

:star2: Happy Day :star2:

That’s the breath of fresh air you are looking for, because then your editor will load, and crash on game start instead of on engine load (if crash even still occurs)

:heart:

Rama

I have tried that, and the program still crashes. I don’t seem to have a way to recompile the code.

I didn’t really expect this to work, as this wasn’t a problem until today.

The crash report does not change.

Are you using Visual Studio to compile your code?

I’d highly recommend doing that if you are not already.

Then you will have LOTS of breaths of fresh air!

:rose: As many compiles as you want! :rose:

After installing, right click your .uproject, Generate Visual Studio Project Files

Then, right click the .sln and open with visual studio, and compile and you can compile Infinity Times with no crashes.

:heart:

Rama

I am using Visual Studio to compile the code, but the compile option doesn’t seem to be available without first launching Unreal, which crashes.

Is there a compile option in Visual Studio that does not require Unreal to be open?

[EDIT] I will likely have to catch up with you tomorrow about this. It’s getting late. Thank you in advance, though.

Maybe try setting your project level to be Startup Project?

and then build option specifically on the project name:

Please show your VS setup if the above does not work!

:heart:

Rama

Okay. The most confusing part was that when I opened Visual studio without launching Unreal, the Solution Explorer view was not visible. I found that I could drag and drop my project’s *.sln file into Visual Studio and I was able to attempt a rebuild of my project.

It got me better feedback, so I know that my EaglePawn.cpp file isn’t so much the issue. But apparently my ObstacleSpawner code is the issue, but it’s telling me that the error is in the generated cpp file, not in the code I wrote. Below is the error output code I’m seeing.

image

It would appear that you are calling StartSpawn in execStartSpawn, but StartSpawn does not exist, or cannot be found because it’s in another library somewhere?

I had this issue. I am not sure about coding things. But my problem was about deleting some project files or something. When i click material editing or rendering, i had crashes. My solution was:

  1. Verify your project files
  2. Verify your engine on Epic Launcher
  3. Remove and reinstall engine on Epic Launcher
    Restart your pc (optional)

Try all this methods and one of them will fix your problem. After try 3rd solution you will get crash for once or twice but if you have crash more than two, your problem different. I solved my problem with those methods.

Note: Don’t delete your project files on your “Operation System” if not needed. Use engine for deleting.

→ Providing :zap: More Breaths of Fresh Air :dash:

What in Heaven is StartPlay?!

:giraffe: You really need that? :giraffe:

Shouldn’t You be using BeginPlay?

If you really need whatever StartPlay is, You probably have to add the actual function definition in your .cpp, because it is not finding it apparently

void AObstacleSpawner::StartPlay(...etc....)
{
   call super? 

//What is this?
}

That’s what unresolved external symbol means, the definition (.cpp) can’t be found to match the declaration(.h).

Other times this appears is if you are using a class where the definition is tucked away in a different module, which you then have to include in your build.cs

General Rama Forum Feedback

If you really want great answers from us, you gotta show us more code

.h and .cpp at a minimum, of whatever class is malfunctioning :boom:.

In the meantime, you get a Forum A++ For Persistence! :rainbow:


Rama: :zap: Persistence = Victory! :zap:


:heart:

Rama

Sorry for being offline for so long.

It turns out that that UFUNCTION StartPlay() was indeed the cause of this perpetual crash. I was able to open the *.h file in Visual Studio by itself, and then load the *.sln file in Visual studio after saving that file in order to rebuild the project.

Now, when I launch my uproject, the engine does not crash.

Victory!!!

(Rama: :zap: Persistence = Victory! :zap:)

:heart:

Rama