Objectfinder cannot find a blueprint

I have a blueprint class extended from a c+= class called BaseProjectile

ABaseProjectile* NewProjectile;
static ConstructorHelpers::FObjectFinder<ABaseProjectile> BaseProjectileObj(TEXT("/Game/Projectile/BaseProjectile/Blueprints/BaseProjectileBP.BaseProjectileBP"));
	NewProjectile = BaseProjectileObj.Object;

But when I open the project, a warning shows that it couldn’t find the object.

I gen this when I copy the reference of the blueprint


Here is an example on how to get the CharacterBlueprint assigned to the GameMode.
Thats from the FirstPersonShooter Tutorial.

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

I guess you need to change a bit of your code.
The ObjectFinder is Searching for UBlueprint and not for the ABaseProjectile.
And the rest of the line should be what the reference says.


Note that the cast in the if will differ from yours, because the DefaultPawnClass is a UClass and your class is ABaseProjectile.

(: Hope that helps you.

Ok it helped. But it gives a pointer to the class. I just want the class name to spawn it later. How can I get the class?

CurrentProjectile = ABaseProjectile::StaticClass();
static ConstructorHelpers::FObjectFinder<UBlueprint> BaseProjectileObj(TEXT("Blueprint'/Game/Projectile/BaseProjectile/Blueprints/BaseProjectileBP.BaseProjectileBP'"));
if (BaseProjectileObj.Object != NULL)
	CurrentProjectile = Cast<ABaseProjectile>((UClass*)BaseProjectileObj.Object->GeneratedClass);

I guess it is done by using


Isnt this working? :

CurrentProjectile = (ABaseProjectile*)BaseProjectileObj.Object->GeneratedClass;

You should be able to spawn this Variable somehow :open_mouth:

Nope that doesn’t work.

This works though

CurrentProjectile = (Cast<ABaseProjectile>((UClass*)BaseProjectileObj.Object->GeneratedClass))->GetClass();

I tried this

CurrentProjectile = (Cast<ABaseProjectile>(BaseProjectileObj.Object))->GetClass();

it also crashes the editor

CurrentProjectile = (Cast(BaseProjectileObj.Object->GeneratedClass)->GetClass());

Also crashing the editor. How can I get the class instead of the pointer?

Just to let you know why I am going to need to blueprint class, I am spawning the actor win the world.

GetWorld()->SpawnActor<ABaseProjectile>(CurrentProjectile, SpawnLocation, SpawnRotation);

I use this method:

// header

/** Stores reference to BP base character */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = BPClasses)
UClass* BaseCharacterBP;

// .cpp constructor

// Save reference to base character BP
static ConstructorHelpers::FObjectFinder<UClass> BaseCharacterBPClass(TEXT(/* ref */));

if (BaseCharacterBPClass.Object != NULL)
	BaseCharacterBP = BaseCharacterBPClass.Object;

Here I’m finding a character blueprint, but I assume it would work with all types of actors. Then I can call SpawnActor with no issues: