Spawning child class data only actors creates # classes % 32 nulls

Just a quick one.

I created a crafting system and use an actor class called craftingMaster which just holds a struct (isUnlocked bool, integers for each item required in the recipie) and an array of classes for each recipie called craftingRecipieClasses (a manually set array of each child class BP of craftingMaster since theres no way in BPing to access assets not in memory at runtime to build the array automatically)

I then create child classes (as in right click → create blueprint based on this) for each “recipie”.

I then placed craftingMaster in the level (again no mesh, just a BP with 2 variables).

Then to start building the crafting system to create a GUI I used the following logic to spawn the child classes and build an array of the actors to get their individual data: (written verison at the bottom before I added the fix and because its hard to read)

Very oddly this created each child class but it also created 28 null actors (28+4 real classes = 32).

So I did a isValid check and that got rid of them but then I tried adding a new child class.

2 issues.

1) First it wouldnt recognize new child classes unless I deleted the masterCrafting actor from the level and put it back in manually. (This was later fixed by just spawning the actor first before anything else) which felt odd, dont know if this is a bug or intentional or just the way blueprints work in this situation

2) Secondly, once I did delete and re-add the masterCrafting parent class it would recognize new children classes but I still got the number of classes % 32 nulls. So for 5 classes I had 27 nulls, 6 classes 26 nulls etc.

When I did do the fix of spawning masterCrafting intitally it fixed the nulls and the not detecting new children classes but thought I should mention this anyway.

FirstPersonCharacter :: BeginPlay() → GetAllActorsOfClass(craftingMaster) :: Get[0] pull of the the and get craftingRecipieClasses which plugs → ForEachLoop()

ForEachLoop
1.SpawnActor(Class = array element (aka craftingRecipieclasses), Transform = 0,0,0 0,0,0 1,1,1, SpawnIfColliding = true)
2. Take returned actor and Add(recipieActorsInLevelArray[])

Sorry for the long post. If you’d like me to replicate this in a fresh 1p template project to test and give simpiler instructions and a clearer picture I will gladly.

so if im following correctly youre having trouble actually spawning the item you are trying to make? the way i handle this in mine is. I have a struct array of Recipe in the struct there is a class variable which points to the item class that is being created( a child of my master pickup class) so for the button clicked(the recipe) i get the recipe that goes with it and run spawn actor from class, hook up the class from the recipe. the problem im having is finding the needed items in my inventory and removing them when i click the button to build them. I am currently keeping both the inventory and the recipe arrays in my character BP

They spawn just fine. But if I dont spawn the master parent class instead of placing it in the level manually, it will only detect children classes that were made up until you palced it in the level.

Not a big deal, now I juts spawn it at runtime.

But with it placed in the level and then doing a GetAllClassesOf(ParentClass) it generates 32-(number of children classes as nulls)
so if i have
Parent Class
-child 1
-child 2

and do GetAllActorsOfClass(ParentClass) → SpawnActor(AllFoundClasses) → IsValid? ( Valid → PrintString(DisplayName), NonValid → PrintString (display name) + “not valid class found”))

I get
Parent class
Child 1
Child 2
null not valid class found
null not valid class found
null not valid class found
null not valid class found
" " and so on 30 times to make 32 total

If I had 15 child classes + the parent to start with to make 16 for example, I’d get 16 nulls.

If it sounds worrying I will try replicating it on a fresh project with easier instructions to replicate.
I’ve already fixed the problem so I cant upload the project.