My NPC Pawn has an array of Objects. The NPC’s AI Controller needs to use and manipulate this array of Objects, including using Remove Index (which alters the array, not just the array’s referenced objects). I can make this work by creating a local copy of the array within the Controller, manipulating that array, then setting (overwriting) the original NPC’s array to the Controller’s now altered array. But I would much rather be using the real array. Is there a way to have a local array variable which is actually the original array by reference in Blueprints?
Or to put it another way, I want my code to operate on the original array like:
[Get Controlled Pawn] - [Cast to NPC: As NPC] - [Target (get) Object Array]
but I’d much prefer if I could do that with a simple variable like:
[Object Array Ref]
so that I keep my code clean and readable.
The main problem that prompted this was that I realized that, while the Controller had been keeping it’s array clean and tidy, the original array on the NPC was much longer and filled with empty Null pointers. That meant the NPC’s array gave it the wrong Length and screwed up loops and checks used in other places in the code. While fixing it I figured I should figure out the cleanest way to do it, rather than my current overwrite-with-a-copy fix.