Non-empty array returns length of zero?

Hi there,

I have encountered a weird issue with a function of mine that actually used to work before I upgraded to 4.19.2.

The part of the function of interest should get all instances of an actor array in the world. For the test, I only placed one instance in the scene. However, even though the array returns the one and only instance (instance zero), when I get the length, it finds that the length is zero, altough it should be one. How can this be? Even stranger is that appearantly zero minus one results in zero (??) and then then when zero gets plugged in into a getter from this array returns none (although instance zero should be there).

Please checkout the screenshot attached.

I am not sure if it is related, but another change in the version of the engine is that somehow I can’t use the “get a reference” when I pulled from the array. Only get a copy is found. If I turn off context-senstive I can force to put in “get a reference” but then it is immediately converted into a “return a temporary copy”. I am not sure if this is the cause, as in order to find the right instance a copy should suffice.

Many thanks for a hint.

Have you attempted trying to save the array locally as a variable and see if it’s 0/null there?
I’ve had issues before where the array gets cleaned up or falls out of scope if I don’t save it as a local variable if I don’t use it as soon as I get it.

I will give this a try! I have worked with arrays in the exact same manner dozens of times (not saving the array) , and never had this problem. Maybe they changed something in 4.19…

Nope, it is not working even if I store the array in a variable. The length is still zero even though the instance sits there.

I got it. So I managed to fix it by reparenting my blueprint actor to “actor”. Previously it was a child of “target point”.

It feels like a bug to me considering the fact that targetpoint (an engine class) belongs to the class actor (which is kind of obvious because you can place it in the world). But while in 4.16 this was no problem (and the same function worked there), here (4.19) the elements of the array did not seem to be valid.

My blueprint actor “spawn point” was created by placing a target point into the world and “clicking add blueprint / script”.

So in case you experience something like this in your project where you cannot get instances of an array (even though they seem to be present in the array), then just checkout your blueprint or c++ class and try reparenting it.