Blueprint Array Shenanigans

Okay so this is a super weird problem, and I cannot figure it out. I’m working on a space battle game, and specifically for the purposes of this question, I’m working on the system that checks for crew in a room to determine their skill in operating the system in the room. I won’t get into mechanical details, because my problem basically boils down to this:

I have multiple arrays of “crewmates” (a class I made based on Character that will hold logic for your crew), and the arrays are seemingly starting with 1 element, even though I am not setting any defaults, and there isn’t even a crewmate in the level when I’m in PIE that could be in said array. And yet, when I compare the length of the array to see if it is greater than 0 to determine if I parse it, the branch passes, meaning the array supposedly has a length greater than 0 when nothing is in it.

The exact error message I get is this:

Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_Array_Get_Item from function: ‘getCrewReactorSkill’ from node: Set skill in graph: getCrewReactorSkill in object: Room

Here is an image of the graph this error is referring to. Again, there is not even a crewmate in the level (as per the level browser during PIE), so there is no way that the array has an element in it, and yet, it’s passing the length test anyway.

IMAGE: http://imgur.com/yla9zo3

I have some other issues that I think may be tangential to this one, but I will save asking those for after I get this question answered since it may clear up the others.

Thanks for your help!!

EDIT: The function where this error is occurring is a ‘pure’ function, if that makes a difference, though I tested with both pure and unpure and the error was the same.

Simple to Answer. Your array has indeed something in. The Problem is the Value it refferncing is Nothing/Null/None and your loop will still get this “None” therefore the “Runtime Error: Accessed None” you try to get Access the Reactor Skill Property of Nothing.

Why is there already a Value?
Well that is something only you can tell. It could be that you added a array element in the Control Crew Array as default but never but something in there. It also could be that you Added a Control Crew to the array and than deleted this specific Control Crew Object but you never removed it from the array now it sits there and points to a Destroyed Control Crew Object (Nothing/Null/None its gone not accesible anymore)

Arrays never remove Items automaticly for you you have to do it yourself. You can check if a Object thats in the Array is Valid with the “IsValid” node before you try to do something with it that will prevent a Crash but will not cleanup your array =)

okay I went back through my blueprints and found the problem. I was missing a check to see if an input class (crewmate input) was valid or null. Lol me…thanks!