How would I create correctly spawn a BP that is a subclass of a c++ class through c++ code?

I’m working on creating an inventory system from scratch. Currently, I have an ItemCache (C++) that I will use to create different subclasses for containers (vaults, storage boxes, player death caches, etc).

I’m stuck on understanding how to approach this situation. I’ve gone over a few posts similar to this issue but ran into errors along the way.

I’ve attempted attaching:

	UPROPERTY(EditDefaultsOnly, Category = "ItemCacheSpawning")
		TSubclassOf<AItemCache> DeathCache;

But whenever I attempt to use ‘DeathCache’ I receive errors and forced to use AMyPlayer::DeathCache instead. (this was different from a snippet I ran across)

Also, I seem to not be able to access the functions I’ve created for DeathCache.

I am looking to store objects in the death cache, so I would need a way to send the contents from the player’s inventory newly created ItemCache as well.

Just currently lost at the moment on how to approach this.

in you spawn function

	if (DeathCache != nullptr) {
		FActorSpawnParameters params;
		params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
		params.bNoFail = true;
		 
		FVector SpawnLocation = FVector(0, 0, 0); /// set your spawn location
		FRotator SpawnRotation = FRotator(0, 0, 0); /// set your spawn rotation
		FVector SpawnScale = FVector(1, 1, 1); /// set your spawn scale		
		FTransform spawnTransform = FTransform(SpawnRotation, SpawnLocation, SpawnScale);
		AItemCache* item = GetWorld()->SpawnActor<AItemCache>(DeathCache, spawnTransform, params);
		
	}

And you can return the item if needed.

I would probably make a spawn function passing in the transform from an external source