Sorry, im very new into Unreal, what is CDO? If I understand right, and my charcter’s class name is AMyCharacterCPP, then CDO is AMyCharacterCPP::AMyCharacterCPP func. If so, yes, im initializing it in CDO.
Didn’t noticed you called CreateDefaultSubobject on FlashlightComponent…
FlashlightComponent is the object that is supposed to be initialized. You can’t call CreateDefaultSubobject because it doesn’t exist yet.
You need to call:
FlashlightComponent = CreateDefaultSubobject(TEXT(“Light”));
and you were putting it in the CDO (Class Default Object). It’s the part of code that in part resembles a pure c++ constructor where default values are set.
It has the same method name as the class so in your case
AMyCharacterCPP::AMyCharacterCPP though the passed in parameters can be different depending on implementation.