Why can't i create a ADirectionalLight in c++?

Hi everybody,

I get a crash when trying to create a ADirectionalLight in my gamestate (which is set to be the default GS in my game).

I use the following code:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = YagLight)
	ADirectionalLight* YagDayLight;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = YagComponent)
	UStaticMeshComponent* YagTest;

----------------------------------------------------------

YagTest = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Test"));
YagDayLight = ObjectInitializer.CreateDefaultSubobject<ADirectionalLight>(this, TEXT("Day light"));

The UStaticMeshComponent is correctly created, but the ADirectionalLight (exactly the same code) gives a casting error and a crash.

I can create a directional light manually from the editor in my gamestate BP. The crash occurs only when using c++ with a ADirectionalLight.

Please let me know if i am doing anything wrong here.

Cheers

Cedric

Oh i’m so stupid, didn’t think to use UDirectionalLightComponent !!

I should try to sleep a little :-)))