Setting TSubclassOf<> property in config

Hi,

I’ve extended the UAISense_Sight by deriving from it by a UAISense_SightNew class. Now the UAISenseConfig_Sight has a property TSubclassOf< UAISense_Sight > Implementation; where the default value of this property is loaded from config file.

I editted the DefaultGame.ini to set the Implementation property as following:
[/Script/AIModule.AISenseConfig_Sight]
Implementation=Class’/Script/ProjectName.AISense_SightNew’

The problem is that ProjectName module is not yet loaded when the UAISenseConfig_Sight CDO is being created, what results in the Implementation == NULL.

Is there any way to fix this or am I bound to select this by hand in every instance of UAISenseConfig_Sight I create?

Hey,
maybe not a cleanest solution but works like a charm.
Thanks for the quick response!

Yeah, there’s a problem with configurable values that point at project-specific classes. A workaround for it would be to update that information upon your sense’s CDO (Class Default Object) creation, like so:

UAISense_SightNew::UAISense_SightNew(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	if (HasAnyFlags(RF_ClassDefaultObject) == true)
	{
		UAISenseConfig_Sight* SightConfigCDO = GetMutableDefault<UAISenseConfig_Sight>();
		SightConfigCDO->Implementation = UAISense_SightNew::StaticClass();
	}
}

Hope it helps!

Cheers,

–mieszko

My less ideal workaround is using FString ClassPath instead, then FindObject<UClass>(ClassPath) then check it by IsChildOf<UAISense_Sight>()