No announcement yet.

Get Random Child of Class

  • Filter
  • Time
  • Show
Clear All
new posts

    Get Random Child of Class

    I have a system where I have something like BP_Bathroom_01 which inherits BP_Room. I want to randomly choose a class that inherits BP_Room and spawn it in the game. I could put all the classes in an array and generate a random index, but I would like something more automated.

    For example, if I create a new asset called BP_Living_Room_01, my blueprint will automatically see it without and further input on my part and be able to spawn it into the game.

    Any ideas?
    - Alex.

    I don't believe it is possible to get a list of classes inheriting from a base class (unless they are already spawned, then you can get the instances with "Get All Actors of Class").


      I guess I'll have to do it a bit more manually then which is a shame.

      Oh well, thanks for the help.


        Yeah there doesn't appear to be an easy way to find all children that inherit from a particular parent. Unless you are adding thousands of different 1s perhaps just go with an array that you manage from a dataset or enumerator?


          probably can do this since in the engine you can get a drop down list of classes deriving from a parent
          Consider supporting me on patreon

          Weapon Master and VRE Merge TUT

          Life Art Studios | Discord | End of Days - VR Zombie Survival