Empty Constructor Not Called, BeginPlay Is, Nullptr Violation

In a C++ class I am creating a component inside of the empty constructor. In the BeginPlay method im accessing the component but the component is a nullptr. I’ve set a breakpoint inside of the constructor and noticed that it’s not being called, but the BeginPlay method clearly is. Wonder why the empty constructor is not being called.

Note that the c++ class is a parent class of a blueprint and this might point to a potential reason. I guess a different (implicit?) constructor must be getting called instead.

Actually, EnemyAbilitySystemComponent is set on line 13, but by the time line 19 is reached it’s back to nullptr. That’s odd!

Solution: I modified the constructor to take an ObjectInitializer and now the constructor is being called. Then I reparented the blueprint (to a character blueprint) and reparented a second time back to my c++ class (deriving from character).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.