Spawning an actor from just the path in c++

For a blueprint you’d want to use FSoftClassPath instead of FSoftObjectPath, and you then need to append "_C" to the end of your object’s path. You can then use FSoftClassPath::TryLoadClass to load and get your UClass pointer, which you can pass to SpawnActor

So maybe something like this, I think:

const FSoftClassPath BlockPath(TEXT("/Game/Cas/BuildingBlock.BuildingBlock_C"));
const UClass* BlockClass = BlockPath.TryLoadClass();
checkf(BlockClass != nullptr, TEXT("expected non-null class"));
GetWorld()->SpawnActor(BlockClass, &SpawnPos);
2 Likes