Possible to have UPROPERTY() that takes a blueprint?

I’ve been looking at all the demo code and from what I can see when a blueprint is attached to say the DefaultPawnClass in a GameInfo descendant its done in the constructor via a hard coded string with the blueprints path. This causes problems when you go to delete said blueprint because there is a constant reference to it. I was wondering if there was a way to expose a UPROPERTY, in the GameInfo, that took in a blueprint much like you can do with Unity and their GameObjects/Prefabs?

Yes this is very possible!

I’ve actually proven this works as I do what you’re saying for my shooting character class.

The character takes in a blueprint for a projectile, and if the BP is valid the projectile is spawned.

My code assumes that the projectile BP will have a certain base class, but that’s pretty reasonable, and there’s no hard coded path :slight_smile:

in the .h file

//Projectile BP 

UPROPERTY(EditDefaultsOnly, Category=ProjectileBP)
UClass* ProjectileBP;

in the .cpp file

//no current projectile class to spawn?
	if(!ProjectileBP) return;
	//~~~~~~~~~~~~~~~~~~~~~~
	
	
	//Spawninfo
	FActorSpawnParameters SpawnInfo;
		
	//SpawnInfo.bNoCollisionFail = true;
	SpawnInfo.Owner = this;
	SpawnInfo.Instigator = this;
	//spawn creature
	AVictoryProjectile* Projectile = 
		GetWorld()->SpawnActor(
			ProjectileBP, 
			Origin, 
			ShootDir.Rotation(),
			SpawnInfo 
		);
	
	if(Projectile) Projectile->InitVelocity(ShootDir);

again make sure to always check that the pointer is valid,

especially since after your first compile it wont be valid till you go into editor and set it on the character blueprint (or any blueprint really)

You could also use TSubclassOf or (I think) UBlueprint*

Hey thanks UClass* worked as far as binding the blueprint trouble now is that it seems that DefaultPawnClass gets locked after construction and will spawn default even if set in InitGame()

Nope I’m an idiot (Didn’t set PIE to use my new blueprint of GameInfo) it works fine!!!