when I add actors to an array I used the index of the array (saved in a variable on another actor) to reference items in the array.
I feel a bit daft but I realized that when I removed something from the array the reference is no longer valid as the array re-shuffles, what’s the best way to deal with these types of references ?
I have items 0,1,2,3 in array, I save the reference to index 3, I delete 2 and now my reference to index 3 is no longer valid…
when you remove an index you could remove it like this:
The reference will now be invalid and the code won’t execute if it is not valid.
Hey there @muller191! In addition to Lizard’s info, it kind of depends how you are using the array. If your array is going to be everchanging you may want to take the reference you had before and make it a reference to whatever actor you pulled from the array. Or if you have an ever changing array and each of the actors are unique, you can take that actor’s reference and keep it, or if you need to find it’s position in an array you can search for it.