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
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)