Invisible/Ungettable/Non-Existant Directional Lighting created...?

This is my constructor:

ADayTime::ADayTime(const class FPostConstructInitializeProperties& PCIP)
	:Super(PCIP)
{
	// Default values
	DayLength				= 240; // 4 hours
	YearLength				= 168;
	CurrentGlobalDayTime	= 120.0f;
	CurrentGlobalDay		= 84;
	CurrentGlobalYear		= 1;
	bTimeIsFrozen			= false;
	LocalLatitude			= 45.0f;
	UpdatesPerDay			= 3600; // Every 0.1°
	NextUpdate				= 0.0f;
	
	// Create the Atmospheric Fog and Directional Light Components for the Sun
	AtmosphericFogComponent = PCIP.CreateDefaultSubobject<UAtmosphericFogComponent>( this, "DaylightAtmosphericFog", true );
	SunLightComponent = PCIP.CreateDefaultSubobject<UDirectionalLightComponent>( this, "DaylightDirectionalLight", true );

	// Set the Direction Light and Atmospheric Fog Settings
	if( SunLightComponent && AtmosphericFogComponent )
	{
		// Atmospheric Fog
		AtmosphericFogComponent->bVisible = true;
		AtmosphericFogComponent->SetMobility( EComponentMobility::Movable );
		AtmosphericFogComponent->SunDiscScale = 1.6f;

		// Direction Light
		SunLightComponent->bVisible = true;
		SunLightComponent->SetMobility( EComponentMobility::Movable );
		SunLightComponent->SetCastShadows( true );
		SunLightComponent->bAffectDynamicIndirectLighting = true;
		SunLightComponent->IndirectLightingIntensity = 0.3f;

		UpdateSun();
	}

	// Activate the Tick function
	PrimaryActorTick.bCanEverTick = true;
}

I create 2 components, a Directional Light and Atmospheric Fog…
For some reason there are now 2 directional lights. One I control over that pointer which works fine, just like the atmospheric fog that does what its suppose to. Then there is another directional light which seems to have melted into my actor which is nothing more than a AActor.

I can change the direction of the “shouldn’t be existing”-lighting by changing the rotation of my actor in the scene, which shouldn’t do anything because I don’t set a RootComponent. I have printed out all components with GetComponents(), but that only shows the 2 I actually added.

This completely messes up my scene lighting, is there something I did wrong? Am I not allowed to add 2 components or something like that?

Hi Tingle,

What versions of the Editor and Visual Studio are you using? Do you see this same behavior if you create a new project from one of the templates and recreate this actor in the new project? Would you be able to provide the full .h and .cpp files so I can try to reproduce this issue?

.h

.cpp

Ill try in a new project, Thirdperson C++ run from VS as DebugGame Editor → Debug → Start new Instance

Think you could also give me some tipps on this issue as well? https://answers.unrealengine.com/questions/78344/tassetptr-not-valid-on-restart.html its a real deal breaker atm.

Ok I tried it, it works fine in the new project - I don’t have the translations either which is what I have in the original project which shouldn’t be there…

Also, the TAssetPtr problem I have doesn’t exist there either… I don’t need to reload the assets…

So what could it be?

Ok I feel like an idiot now… I recreated the actor and everything works as intended… the Asset thing works fine as well. Guess I should recreate actors when ever I do new things like adding components or assets.

But I suppose it’s still a bug/issue for bugging up over time :/?

I’m glad to hear that everything seems to be working for you now.

We recently did some work on an issue where Blueprints were not being updated when the class they were derived from was changed. This sounds similar to that issue. Do you happen to know what changes you made to the class before this issue started happening?

The issue with the TAssetPtr not working seemed to have been right from the start, when I added them.

And the issue with the non-existant light which seemed to be the root component showed when I added the UAtmosphericFog component to the class.

I did some experimenting with removing and re-adding the UAtmosphericFog component in the class and was not able to see any behavior like you had described. If you happen to run into something similar again, please let us know.

Making changes to the base class that you are deriving Blueprints from should become a smoother process in the future. We apologize for any inconvenience that you are currently experiencing.

Thing is, I’m not using blueprints :stuck_out_tongue:

Oh, sorry. I thought you were creating a Blueprint from the Actor you created, then placing the Blueprint in the level. In your case, it should not be necessary to recreate your Actor class any time you want to add a new component.

I am curious, when you noticed the unusual behavior from your Actor, did you try doing a clean rebuild in Visual Studio?

No, I didn’t do a rebuild, all I did was recreate the actor to fix it as mentioned above.