[4.17] Loading a Blueprint Actor properly on C++


I made a RPG game, I convert from 4.16 to 4.17 and now I got a crash from creation actor

First here is the code

    ConstructorHelpers::FObjectFinder<UBlueprint> iaPawnBPClass(TEXT("/Game/Blueprints/RPGCharacterBP"));

    if (iaPawnBPClass.Object)
        characterBP = (UClass*)iaPawnBPClass.Object->GeneratedClass;

void ARPGIAController::CreateEnemy_Implementation()
    UWorld* world = GetWorld();

    if (world)
        for (int i = 0; i < nbMonster; ++i)
            ARPGCharacter* const newCharacter = world->SpawnActor<ARPGCharacter>(characterBP, characterStartPositionArray*, FRotator(0.0f, 180.0f, 0.0f));

            //Init Data for newCharacter




Well I know for sure not the right way to do, but on previous verson that work now it’s crash. I take from one of the sample of unreal engine 4.

So the idea is to search the blueprint file for character RPGCharacterBP (which are also a cpp file) and use it to spawn an actor. On previous version the variable CharacterBP was not null , now that strange , during the loading it’s not null but when I spawn the actor this variable become null…

Can someone help me to load properly (I’am not against to change totaly the way to load an BP actor) an BP Actor


Anyone can help me ?

If “CharacterBP” is null, that means it wasn’t found or GeneratedClass is null. You’re just going to have to step through and see what’s going on. You may want to manually open up your RPGCharacterBP in the editor and click compile (although Blueprints should be auto-compiled on load).

Everything looks fine, you’re just going to have to figure out where things are breaking on your own since we don’t have your project.

Thanks ExtraLifeMatt

But that why it’s strange , because on the previous version there is no issue… and now with the new one is crash

Moreover , indeed I’am using a break point and go 'line by line" … At the initialization of CharacterBP the variable is successfuly set (and not null) and when I need it to create the character… The variable become null…

I don’t undestand why :((

4.24 it Work. Good Luck

UObject* SpawnActor = Cast<UObject>(StaticLoadObject(UObject::StaticClass(), NULL, TEXT("/Game/DEXIED/Foliage/Tree/BP_TreeDestroyed_Style_1.BP_TreeDestroyed_Style_1")));

UBlueprint* GeneratedBP = Cast<UBlueprint>(SpawnActor);
if (!SpawnActor)
GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Red, FString::Printf(TEXT("CANT FIND OBJECT TO SPAWN")));

UClass* SpawnClass = SpawnActor->StaticClass();
if (SpawnClass == NULL)
GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Red, FString::Printf(TEXT("CLASS == NULL")));

UWorld* World = GetWorld();
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
World->SpawnActor<AActor>(GeneratedBP->GeneratedClass, GetActorLocation(), GetActorRotation(), SpawnParams);