How can I call a Blueprint function inside C++ code?

Here is an example from the First Person Shooter C++ Tutorial from epic:

static ConstructorHelpers::FObjectFinder<UBlueprint> PlayerPawnObject(TEXT("Blueprint'/Game/Blueprints/BP_FPSCharacter.BP_FPSCharacter'"));
   if (PlayerPawnObject.Object != NULL)
   {
       DefaultPawnClass = (UClass*)PlayerPawnObject.Object->GeneratedClass;
   }

The ContructorHelpers::FObjectFinder is helpfull to find Blueprints. In this example it finds the

TEXT("Blueprint'/Game/Blueprints/BP_FPSCharacter.BP_FPSCharacter'")

So you need the exact folder structure and BP Name. After that, the if checks if the UObject is not NULL and saves it’s Class by Casting the GeneratedClass to a basic UClass. I guess that could help you :X

1 Like