Can anyone tell me if there is a way to get all children from parent class. For example , i have a FatherWeapon class and i want to get all children of that class for example: Assault, Shotgun, Pistol etc… Can i get all those children in some Array or anything like that? I would mainly like to get a Children Class!
There is a Node called Get All Child Actors but how does it work? Do i have to Spawn FatherWeapon class and then connect it’s reference to Get All Child Actors and get array? Because that gives me nothing.
Also there is Get All Actors Of Class but in order to get them, they have to be into Level and i don’t want them to be in level i want to spawn them when i need them.
Thank you very much, but is there some more automatic way? I want to make it more dynamic so when i add some child later it’s added automatically to the array.
TObjectIterator in C++, I took this snippet from the AnserHub thread I linked at the bottom. It does appear you need to actively do a search, assuming you aren’t trying to add new classes at runtime, it can do it once at the initialization of the class that needs the list and add them at that time.
On begin play add “self” to an array you’ve created in the Parent Class…for example in my game all enemies that spawn as Alice goes about her level Add themselves to an Enemies Alive Array so that I can count down to Zero when Alice kills them all (they remove themselves from the array when their life hits zero) and is no longer in Combat…
I got a base_Player, I want to get all children of the players. Then make reference to that one.
So I can use there variables and stuff in Player controller.
Class array of Base_Player - for each loop etc… what next?
I’m going down this rabbit hole in blueprints. Unfortunately your solution requires the child actors to be spawned. The need is to do this without spawning the children. Is there a way?
If the actors are already spawned into the world, you can use “Get All Actors of Class” and select FatherWeapon.
If the actors are not spawned into the world but you still want to get a reference to them, it’s best to use a Structure, DataTable and Function Library in combination. This is the best solution. You can either search for this on YouTube or take a look at https://gameinstruct.com/ - Good resources there as well.
Now I can use the GetItemInfo function I made in the function library anywhere I want. I just have to give it the item name and I can get all the values for that item (which reads from the data table):
Thank you so much for this! Possibly a noob question here, seems like a chip shot now, but once we have this set up, is it possible to for-loop each row and return matching results? A few use cases:
I want to for-loop through all rows in the data table and return , for example, all classes that have variable X Y or Z.
Return all Classes that have rarity Poor
Sum the values of all “Weight” variables.
I may just have to try this to discover what method would work.