I just started using Unreal a few weeks ago so I’m technically still a noobie to this, but I was following an Unreal Engine course when I made a slight tweak to a C++ file and then Unreal immediately crashed and I have not been able to open the project since, everytime I try it crashes with the same error. Is there a way to fix the issue or move everything to a new project (It is happening independently of my other projects). Here is the crash report it gives me:
This is what the Mover.cpp file looks like and I’m pretty sure the first crash happened right after saving the FString Name = Owner->GetActorNameOrLabel(): include “Mover.h”
Welcome to the Unreal Engine Forums! I’ve saw this exception access violation quite a few times myself. I pulled an older post where some individuals were able to solve the problem. I’d recommend starting with the solutions offered there. If it doesn’t work, post back here and we can look further into the issue and try to find the remedy! Here’s a link to that post. I hope this helps!
There is no owner for a component when the constructor is run, so that pointer is NULL and then you indirect it.
You should either wait for BeginPlay to access the owner or you can set bWantsInitializeComponent to true in the constructor and then override InitializeComponent and access it there (I think it should be available then).
The constructor should only be used to set member variable defaults. Runtime values like the owner will not be set yet.
The mistake of where I’m declaring the variables was when I tried to rewrite the file after my first attempt of removing the code that I typed when it broke. Fixing it made no difference and I think that it would throw errors in the compiler. Originally the variables were defined in BeginPlay().
I went and looked at both DaDon089’s post and the post that was listed in DaDon’s post, both of which seemed to be having issues with Unreal connecting to the internet. I tried all the solutions listed and none of them had any effect. Every Google search I’ve done has rerouted the error code to ones ending in 000 and not 2a8. Also my crashing only occurs in the one project. I will try and make a new one and see if I can replicate the crash.
I created a new base FPS project, put a plane into the scene, added an Actor Component C++ Class to the plane called mover. Moved my variables into Mover.h to make sure they were defined and they were typed as:
AActor* Owner = GetOwner();
FString Name = Owner->GetActorNameOrLabel();
Added this to the UMover::TickComponent:
UE_LOG(LogTemp, Display, TEXT(“Mover Owner Address: %u”), Name);
Nothing happened after testing and running this it wasn’t even printing the UE_LOG, I went back and looked at the video I was following and realized that it was supposed to be
UE_LOG(LogTemp, Display, TEXT(“Mover Owner Address: %u”), *Name);
At which point it immediately crashed on saving it with an identical error code.
After a lot of digging, Unreal was crashing from a dangling pointer and I remembered that code can be compiled outside of C++ after removing the pointers and compiling through Visual Studio Code. I got the project back up.
Oh! Makes total sense! I’m glad that you were able to get it resolved. I also appreciate you marking the solution. That will help anyone who runs into that and searches for the error here. Thanks @Gaming_Tiger101