Projectile.h
UPROPERTY() UPointLightComponent* LightComp;
Projectile.cpp
AProjectile::AProjectile(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
...
LightComp = ObjectInitializer.CreateDefaultSubobject<UPointLightComponent>(this, TEXT("LightComp"));
...
}
void AProjectile::InitProjectile()
{
if (LightComp)
{
...
} else
{
GEngine->AddOnScreenDebugMessage(-1, 50.0f, FColor::Red, "No LightComp!" );
}
}
InitProjectile() is called from the weapon after the projectile is spawned.
The debug message is displayed indicating that there is no LightComp.
Why is CreateDefaultSubobject not creating the LightComp, and what do I need to do to get it to?