Memory access violation issue

You’re trying to dereference ‘TriggerBox’ in the constructor, but you haven’t created the object. That’s why you’re getting an access violation.

You need to use the FObjectInitializer constructor (make sure you call Super too), and use ObjectInitializer to create the trigger box, then you can set properties on it.

e.g.



AOLTest::AOlTest(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
    TriggerBox = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, FName("TriggerBox"));
    //Do Stuff
}


2 Likes