Invalid Array - Inconsistent

So first and foremost, I understand I am not going to give a lot to work with.

My issue is that I set an Array of object in my blueprint, and retrieve it for various reason through my script to read from it.

My setup:
-I set the array (for loop + add) and aside reading, I never touch the array again (delite, add, etc)
-It work fine in all instances but one, on a specific call from another blueprint (it does fire fine, (the for loop), also output completed fine, but adding a ‘‘is valid’’ node return nothing) so the array is ‘‘empty’’ at that specific time
-The variable and the script exist on a game object that is always loaded, no excuses!
-If I try to fire a for loop on a 1 delay second, to print the array, then everything is also fine, printing everything correctly before, while, and after I go through the moment where I call it and it fail.
-I added delays to offset a potential bad timing, or to skip a frame, unsuccessfully.
-I rebooted my PC, you never know!

-I check well over 30 time my setup, and I start questioning if there a thing about array that I don’t understand as a general construct. What would be construct where even when the array is filled, would it return nothing or ‘‘empty’’ ? if there such thing.

I am 3 hour into this one and it puzzle me to no avail.
Sometime you just need someone pointing you in the right direction, so does that ring a bell ?

Thanks!

Pictures would be useful.

1 Like

This doesn’t give you everything, but as far what going on locally,
with the for each loop, that seem to get nil
and the retrigger loop debug that constantly output correctly at all time.

Are you changing stage array anywhere?

You mean the Loop Body doesn’t get executed? I think that’s because you’ve placed a delay node in there. You can indeed add delays between each iteration of a loop, there are workarounds of it, but placing a Delay node after the Loop Body pin is not how you do it.

Oh wait the reason I mentioned this way due to this:

But you also say that the parts before the delay node doesn’t get executed so yes it’s about the array. Anyways I’ll still keep that part above for extra info. Could you show the part where you set up your array?

I only ‘‘make it’’ once (through a add node on a for loop) in the initialization stage of the script.
I also have debug there to insure it doesn’t retrigger.

then I often access it (read) but never ‘‘to my knowledge’’ modify it (add clear etc.)

Yeah, the delay was for debug purposes, and before the for loop.
Thanks for helping :slight_smile:

I upload the image but I doubt the issue come from that place as I use the Array multiple time as reference successfully.

It’s in a function that get executed only once.
(the print at the end help debug to monitor if it get retrigger by any means (its not))

You don’t need a chess square reference variable. Remove it.
Add clear stage square array before going to the first for each loop.
What happens if non of the stage reference integer and stage number aren’t equal?

For the ref variable, It is true that it is not needed, but I got into the habit of making it most of the time because it make most script cleaner, (Or at least that what I think :wink:
-I removed it, for the sake of trying!
-Would there be any reason, aside performance I should get rid of it ?

You are correct about the Clear, it probably will save me some debug time later on! thx!

Also Correct about the Stage ref and the Stage number, I am not that far into that prototype but
I should definitely add a debug warning and fallback, in the case where the referenced stage would not exist.

Now all this doesn’t solve my issue with the Array, (returning something that feel like its empty, in a specific case)
As I mentioned before, it function correctly in around a dozen of other situations I call it (the object array) and my debug tell me that at the very least its initially fully populated, usable before, and after I call for that specific case.

I am very puzzled, to me the impression I get is that the array is full then empty then full again, which doesn’t really make sense with what I do.
Now, I am quite adamant that I did due diligence searching for anything that clear, erase, reorder or anything else than reading it, (I am also not casting to that one anywhere) AND I am also certain that the script is executed to completion, but I am human and the computer is not so I am still combing through my script to find where I inevitably messed up.

Stupid question?
-There no way where trying to read\access an array from 2 different location at the same time can mess it up ? Correct?

Thanks for the Help Dejan33!

Most common reason not to access any element in a array is if you are trying to access it before something is added to the array. Debugging is a process that can take days or even months, depending on the project.