I have a custom AI controller c++ class, from inside which I’m trying to load and run a BehaviorTree blueprint. I use the FObjectFinder to load the BehaviorTree object.
const ConstructorHelpers::FObjectFinder<UBehaviorTree> BehaviorTree(TEXT("BehaviorTree'/Game/Enemies/EnemyBehaviorTree.EnemyBehaviorTree_C'"));
While this code compiles without error in Visual Studio and everything works flawlessly in the editor, the editor’s output log actually states that it is unable to find the object. I’ve been using this method to reference Blueprint classes like BehaviorTrees and UMG widgets for a while now, and only realized this first when I tried to package the project with no success. Also, adding ‘_C’ to the end of the path string causes the same error, except running the tree doesn’t work even when played from editor.
That being said, I’d like to ask: What is the proper way of accessing Blueprint objects and classes from c++? I’m aware that creating a TSubclassOf variable in the c++ class and setting it in a derived Blueprint class is an option, but that would mean creating several child Blueprint classes with no functional difference from their c++ parents, which seems to me like a rather clunky solution (or is that the usual UE4 workflow?).