So, it’s not first time, but now solution from last time doesn’t work. When I try to start my project, UE4 crashes and gives me this sign: Fatal error: [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 2618] UObject(const FObjectInitializer&) constructor called but it’s not the object that’s currently being constructed with NewObject. Maybe you are trying to construct it on the stack, which is not supported.
Here is my AMyCharacterCPP::AMyCharacterCPP() code:
AMyCharacterCPP::AMyCharacterCPP()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
AutoPossessPlayer = EAutoReceiveInput::Player0;
bUseControllerRotationYaw = false;
CamComp = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
CamComp->AttachTo(RootComponent);
CamComp->SetRelativeLocation(FVector(0, 0, 40));
}
Make sure you not trying to do this. You cant have on-stack uobjects inside of (in this particular case) your character, Make sure that your CamComp and other UObjects you may been defined in class definition in header are pointers (“UCameraComponent*” and not just “UCameraComponent”).
Two uobjects created on a stack, while you supposed to define them as pointers and create them via CreateDefaultSubobject(in constructor) or NewObject(at runtime)