Recently, I’ve got a strange and annoying situation.
Well, I wanted to create a C++ project from zero. Then, I was making a character class. And tried to add a camera.
FPCharacter.h
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
class UCameraComponent* FPCamera;
Which situation do I have? Well, when that piece of code in C++ file is deleted, Live Coding works ok. But when I add that code, I’m getting a crash of the engine.
The video below is demonstrating that.
So how to deal with it? And how to avoid that absurd moment?
Looking forward to your answer.
Instead of FPCamera->CreateDefaultSubobject<UCameraComponent>(TEXT("FP Camera")); use FPCamera = CreateDefaultSubobject<UCameraComponent>(FName("FP Camera"));
FText snuck in by there instead of FName :). Also, don’t use → but = to initialize the object.
Live coding does not work with constructors properly. Exit Unreal Engine, build the code and then run the engine again. I tested this code in my project, and it worked. So it must work on yours. I didn’t just type it here
I’m laughing right now because I used the code with Spring Arm (although I wanted First Person View) and it worked correctly, without any crashes! :)))))
But if we look at FP template, we can see the camera without Spring Arm in the character class. Oh God, that’s really idiotic moment…
Solved but it was an eerie solution…
It needs to be reported. I need to write to the UE developers because it is really absurd.
The “disappearing C++ classes” bug isn’t still fixed. And SPRING ARM AS A SOLUTION KEY. Oh God, that’s really irritating moment. I don’t know why. I’m having a scream of my soul right now…