Cast ADirectionaLight

if(DirectionalLight == nullptr)
	{
        // if OtherActor is null or the cast fails DirectionalLight will be NULL.
        // if DirectionalLight is NULL DirectionalLight->GetComponent(); will crash:
        // NULL->GetComponent();
	    DirectionalLight = Cast<ADirectionalLight>(OtherActor);
        if (DirectionalLight != nullptr) 
        {
	       UDirectionalLightComponent* DirLight = DirectionalLight->GetComponent();
        }
	}