How to get all child types from a class? (blueprints)

Hello.

So my question is simple, i’m trying to create a ForEach that would create an instance of all types that belongs to a specific Parent type.

Example: “WeaponBase” and then “Pistol1”, “Pistol2”, “Pistol3” as child.

I would like to spawnActorFromClass, inside a foreach, similar to what GetAllActorsWithInferface would do, but instead of returning instances, I need to return the Type, so I can create the instance.

Is there a way to do this? I would not prefeer to harcode one by one the possible child types, I’d like the game to extend automatically when a new type is added.

hi @leofucci

Ok this is a dirty way, use a get all actors of class on your parent class.
then loop through and do a check to see which are children using

Class is child of

plug parent in the Parent Class and your array item into the Test class

returns bool so branch if true

Anyone having this similar issue where you want to get all child blueprint class assets rather than instances in the current world, here’s a solution that doesn’t require any C++:

Goal is to get these child blueprint assets:

Here’s the begin play:

Individual helper functions:


And the result:
image

Edit: This was done in 5.3 version. There might be differences in the AR filter, AssetData Struct or other nodes.
Edit+: Don’t use Async Load Class Asset node in a for loop, use Load Class Asset Blocking node instead. This was my bad. Async actions don’t work in loops (or maybe it depends on the situation?).

In addition, you can filter items by folder like here:

Here’s the helper function:

This example will get each blueprint asset from the folder/subfolders of a given path.