Let’s say I have custom actor class named AMyActor.
In one of my objects I have:
UPROPERTY(EditAnywhere, BlueprintReadOnly) TSubclassOf<AMyActor> actorPrefab;
Where actorPrefab points at one of the blueprints derived from AMyActor which sits in content browser, not in the scene.
So, during runtime I want to spawn a clone of whatever blueprint or class actorPrefab is pointing at.
The problem is that calling
Doesn’t work, and prints an error (“SpawnActor failed because BlueprintGeneratedClass is not an actor class”).
Now, all the articles online only mention how to spawn objects using hardcoded path, FStaticObjectFinder and FStringAssetReference.
There’s also TAssetPtr which require you to babysit object loading.
How do I spawn thing via TSubclassOf pointer? basically, I want the same kind of workflow as I had in unity, where you specify base class you want to reference, drag content browser asset to it, then clone it at runtime to make a copy.