How to find item de TArray of TSubclassOf

Hi everyone,

I’m trying to find an item inside my custom player camera manager.

I have the DefaultModifiers of the PlayerCameraManager. Inside it, I would like to get a specific modifier from it.

Problem, the DefaultModifiers is a TArray>. And I would like to get my UCustomFocusTargetModfier which inherits from UCameraModifier.

	DefaultModifiers.FindItemByClass <TSubclassOf<UMetaModifierFocusTargetActor>>(&modifier, nullptr, 0);

doesn’t work.

	for (TSubclassOf<UCameraModifier> cm : DefaultModifiers)
	{
		modifier = Cast<TSubclassOf<UMetaModifierFocusTargetActor>>(cm.Get());
	}

doesn’t work either.

If someone has a clue about it. You make my day and my week. ^^

Best regards everyone,

Alex

Ah and I forgot. GetDefaultObject() doesn’t work either because in fact it creates a new object and copy the content of the original object inside.

Ok so I believe this is what you want to do. you know that the array is already of some parent class so just scan through it and try to cast each on down to your custom child class.

for(UCameraModifier* cm : DefaultModfiers){
    UCustomFocusTargetModifier* CFTM = Cast<UCameraModifier>(cm)
    if(CFTM){
        //Do stuff
    }
}

Doesn’t work because there is not any conversion function from TSubclassdOf<UCameraModifier> to UCameraModifier*