Array Index None with Array of Actors - Tracking Actors

I am using 3 arrays to keep track of missiles for a weapon system.
Weapon System has 30 “Slots”, one for each missile.
Index in each Array corresponds to a “Slot” in the Weapon System

Array #1: Array of Scene Component Object References and is Preset at Begin-Play with all the Scene Components which mark the locations for the missiles to Spawn and be Launched from. 30 Indexes (0-29).

Array #2: Boolean Array and is used to track if a Missile is Built (Finished Building and Spawned) in the particular “Slot”. 30 Indexes (0-29).

Array #3: Array of Actor Object References and Index is set to Object Reference of the Missile Spawned in that corresponding “Slot”. If there is no missile spawned, the index is set to “None” by the engine - to do this, when the missile is Launched, I use “Set Array Element” and Using this Array and the appropriate index number and leave the “Item” pin not connected and the system then sets it to “None” (Thats what it says when I watch the array variable in debugging)

When a Missile is finished building, a script checks the next spawn location to see if a missile is already built, if it is it goes to the next one until it finds an empty one - I use the Boolean Array to check this.
That Array Index is passed on to then get the Corresponding Scene Component to Attach to, Spawns the Missile while setting the Index of the 3rd Array to the object reference of the missile spawned and attaches it.

I then have a complicated script for targeting enemies and assigning the Homing Target Component for each missile, tracking if the missile already has a target. And more arrays for tracking that information.

I am accustomed to arrays in PHP, where a key->value both could be alphanumeric or references to objects. They work more like Maps in UE4 however Maps are not editable (well, not really or easily anyway). In PHP I could have easily keep track of the info in all 3 Arrays in a Single Array in PHP, with he Key being the Scene Component Object Reference and the Value being the Actor (Projectile) Object Reference and would also be able to check for a null value (If missile not built, value would be null instead of object reference)

Basically, if I was able to directly change key->values in Maps this would be easy. But to do that you then have to temporarily store the Map Key->Value, Remove the Key and then reinsert the Key with the new Value. And I do believe this changes the order of the map? In PHP with Arrays, it would keep the same order and I could just simply update a value of a particular key as well as reference an index number.

I have the system working but I am wondering if I am missing something with Unreal Engine and there is a simpler, better or more efficient way of doing what I did? I am finding as I am adding the Targeting scripts it just gets more and more complicated and troublesome.

Maybe this is a topic for the forum? If this is better to post on the forum let me know and I will change post to somewhere appropriate on the forum.

After some experimentation I have found that on an actor array I can use “Set Array Element” and connect the array pin and the index pin adn if you leave the item pin unconnected it will set the array element to “None”. You can then do a “Find Item” on the Array and if you leave the Item pin unconnected it will return the first index it finds that is empty or “None” and if all indexes are set it will return -1.

Considering each item of array correspond to each slot you can pack all varables related to slot in to the structure:

https://docs.unrealengine.com/en-us/Engine/Blueprints/UserGuide/Variables/Structs

And you don’t need null anything… why would you do that? Just keep that state in structure indicating it if it’s used or not.

You can go even feather and a lot smarter, self-managing items, by creating object blueprint (or component less actors), which also will contain those variable, but also code that will manage the slot and function which let you manage them from outside. You would hold reference of owning actor in the slot object so slot can reference back . You can also make Blueprint Component and make slot a actor component.

I use structs quite a bit, after I found out about them lol. The reason I did not use them in this scenario was because I did not think it possible to do a “find” on an array of structs? Am I missing something? Cause that would be amazing. I have found to do Find on a Struct but not a find on a value in a struct in an array of structs (without using a loop)? Thanks for the insight of using the variables inside a compinent blueprint with code to manage itsself. I did not think of that. That will help me with ideas down the road for certain! I’m new to Unreal so it is great to get this insight from you! You have given me a powerful idea to play around with! Exciting hahaha