Okay I see a few issues, I’ll keep this as a comment since it doesn’t relate to the original question. First, BP->ParentClass
would be giving you the UClass representing the BP’s parent, not the BP itself. So the UClass for ASoldier, I guess. Are you sure you don’t want BP->GetBlueprintClass()
? Regardless, these are both UClass-derived objects, rather than an ASoldier-derived object, so they don’t implement the interface. You’d need BP->GetBlueprintClass()->GetDefaultObject< ASoldier >()
instead, which you should be able to cast to IUnit. But you can’t add this to the return array, since it’s not a UClass. You should add BP->GetBlueprintClass()
to the array. Note that BP->GetClass()
is definitely not what you want - that just gives the UClass representing the engine class UBlueprint. I hope that makes sense, this stuff can get pretty confusing.