How to add/access classes to/from an array?

I can’t seem to figure out why this doesn’t work on my own. I’m inserting a specific class into an array of classes at a specific location in the array. Then later trying to access that same location to get the class I stored there earlier, but it comes up empty.

If I try to do the same thing with an array of integers it seems to function in the way I want it to.

I may be wrong, but the reason it works with integers and not classes may be due to the fact that integers get passed by value, as literals, while classes are most likely passed by reference, so you need an object reference that is kept in your array. This is just from the top of my head so I might be mistaken.

You correct, thing is UE4 object management system registers classes by making UClass objects which behaves like normal objects, this allows to contain reference classes in variables or arrays not only in blueprint, but also in C++ which is normally impossible. So he trying to do is contain UClass staic object references in array which should work.

I roughly understand how arrays work. I roughly understand how storing actors/classes in variables works. But nothing I want to put into an actor/class array seems to actually get stored in one for some reason.

From my experience, putting ANY kind of class input into a SpawnActor node ends in disaster, even if it initially works fine. It corrupts the return value even if the input is exactly the same. Maybe that is my only problem, but it could affect you as well.

Put print strings on both sides of the Spawn Actor node, to see that the input is what you expect and then confirm that the return value is also correct. Maybe put one in front of your Add Array too so you know what is going in is good.

If that all works, try using the return value on the spawn actor and plug it into something like the Target of a Set Material node. One of my main problems was this conversion working fine WITHOUT Class input(Manual class set on Spawn Actor), and then corrupting on project reload WITH Class input.

Your issue might be different, but if it is the same there may be some bigger problem that the devs need to investigate.

My problem was that I was’t able to put anything into the array or get anything out of the array and I guess I resolved it somehow. I don’t know what exactly happened. Using the exact same setup it wasn’t working. Then I decided to add a tooltip for the class array and it suddenly started working. Removed the tooltip and it was still working. Tried replicating the problem by making a new class array, but now it just seems to work by default.

So while it’s working now, I have no idea what caused it or what I really did to fix it.