How to spawn an actor based on the folder it is in OR based on it's Parent Class

Hi, I have several blueprints called BP_Room01, BP_Room02 etc. that are all in a folder called Rooms and that are all child of the Parent Class BP_SpawnableRoom. I woul like to get all these BP_RoomXX, put them in an array and spawn a random room. I have tried using Get Asset Registry which was able to get all the BP_RoomXX, but I cannot spawn an element from that array using SpawnActorFromClass because the class returned by the array element is Blueprint. If anyone knows how i could get the actual class (instead of Blueprint) from the array element, or how I could get all child actors from the parent class BP_SpawnableRoom into an array, please let me know! :smile:

I’ve just been working with spawnable rooms too. I ended up making a master BP in the scene and made everything child components under various categories in that.

2 Likes

Interesting idea, I will keep that in mind, thank you! :smile:

1 Like

Hi, one question, is there a reason why you would spawn the rooms as actors and not as levels? It seems like a rather unusual approach, I might be missing something .

If you have a reference to a UBlueprint object, what I think you can do is just call the UBlueprint::GetBlueprintClass which returns a UClass pointer that you can then use to spawn an actor, assuming that the class your blueprint derives is an Actor class.

It is my first time trying to generate a map while playing, so I just tried to use what already knew to achieve my goal :sweat_smile:, What would be the advantages of using levels instead of actors?

Well then this is a great video for you

Basically you’d use levels for environment, honestly I couldn’t explain to you what the exact advantages are, as I never heard of anyone using actors for environment. Not sure if there is a case study. Let me know if this helps :slight_smile: