Download

Spawning actor from Asset Registry

Im trying every way possible to spawn an actor from the asset registry. The cast always fails and nothing gets spawned. I’ve tried every way I can think of and the picture below is just an example of what i tried. I googled for hours and hours. Search the forums. I missed it or cant find it. Note i replaced the spawn transform with an empty one to clean up the logic.

What im trying to do is spawn an actor by searching the asset registry for the class using a plain text string. So no hard references.

Thank you for helping!!!

Bump.

I’m interested too. Can someone help to understand this?

The class being returned is just a generic Blueprint class, and so you will need to get the actual asset class and then use the Spawn Actor from Class node. Below is a blueprint node that will get the actual class of the asset.

UFUNCTION(BlueprintCallable, Category = Loading)
static UClass* GetClassFromAssetData(const FAssetData& InAssetData);

UClass* URPGBlueprintLibrary::GetClassFromAssetData(const FAssetData& InAssetData)
{
FString ObjPath = InAssetData.ObjectPath.ToString().Append("_C");
return StaticLoadClass(UObject::StaticClass(), NULL, *ObjPath, NULL, LOAD_None, NULL);
}

PublicDependencyModuleNames.AddRange(
new string[] { “AssetRegistry”}
);

Modified From: