Instantiate a blueprint from C++ then cast to the blueprint's parent class?

Hi,

I am trying to make a system in which quests reside in a preset Quests folder, and each quest has its own folder within that. Then within the quest’s own folder there are one or more QuestSteps. QuestStep is basically just a C++ blueprintable class that defines some properties and flags, etc. But actual concrete quest steps will be blueprints that derive from this class.

So now what I’d like is to have a function that I can call from either C++ or blueprints called CreateQuest and I pass it the name of the quest. The function is supposed to instantiate a quest object (which is mainly just a collection of queststep objects), then go to the folder in blueprints, based on the name and for each file it finds there add it to the quest, then return the quest to the caller. The problem is - I can’t figure out how to instantiate and then cast a QuestStep-derived blueprint. I did find a function called StaticLoadObject but not exactly sure if that’s what I need. If I call this with the proper path (which points to a blueprint that is based on the QuestStep C++ object):

auto obj = StaticLoadObject(UBlueprint::StaticClass(), nullptr, path);

I will get back a blueprint , not QuestStep object. But inside this blueprint object I can see that ParentClass is QuestStep. Where do I go from here - how can I create an instance of this QuestStep-based blueprint and cast it up to QuestStep base so it can be added in the Quest’s array of steps.

Actually , I think I may have figured it out… If I instantiate UBlueprint like above and cast to UBlueprint that will give me a UBlueprint property called GeneratedClass. This seems to be the actual class of the UBlueprint object. So this is what I do now:

UBlueprint* bluePrintObj = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), nullptr, *finalPath));
if (bluePrintObj != nullptr)
{
auto stepObj = StaticConstructObject(bluePrintObj->GeneratedClass);
… Other code logic …

}

This seems to be working OK. It creates a new step object based on the path that was passed in. And the object seems to be working as expected.

But my updated question now is - Does what I’m doing make sense or am I doing something crazy here?