I am just trying a very simple code but getting nullptr (I guess).
This is a part of my header file
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(VisibleAnywhere)
class UShapeComponent* CloseTrigger;
And this is the constructor of my cpp file
ACat::ACat()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
CloseTrigger = CreateDefaultSubobject<UShapeComponent>(TEXT("Close Trigger"));
if (CloseTrigger != nullptr)
{
CloseTrigger->SetupAttachment(RootComponent);
UE_LOG(LogTemp, Display, TEXT("closetrigger successful "));
}
else
{
UE_LOG(LogTemp, Error, TEXT("closetrigger nullptr "));
}
}
And I am getting the error log every time I open my derived blueprint or start the game.
I looked at this forum, google, reddit but only thing I found is that there is a bug in the engine but there is not a real solution.
I was supposed to put USphereComponent in there.
Before doing this, I was trying to do something depending on inheritence and I never noticed that I was trying to create an object of an abstract class.
I find developing C++ on Unreal really stressfull. I am trying to learn C++ by developing on Unreal but the fact that Unreal has its own macros, garbage collector and stuff on top of C++ is a little bit confusing for a noob. In addition to that, if you do something wrong, the whole engine just crashes and wouldn’t open again until you fix the error in your code.
I don’t want to flood this forum with lot’s of questions like this but I guess since I don’t have a senior with me all the time, I have to ask time to time.