How do I access a variable from an array?

I have an array of Objects, and each object within that array has a variable called “Homebase Tile Currently Selected” – what I want to do is go through each object in the array to see which Object has the “Homebase Tile Currently Selected” currently set to True. But I can’t seem to figure out how to access the variable. I feel like I should be able to access it through the Array Element pin, but don’t know how to get there. Any advice?

1 Like

Avoid placing down orphaned nodes like you did with the boolean. If you feel you must do this, something has already gone wrong.


  • either the array is of the generic Actor type only - can you confirm its type? Hover mouse over that array variable, what does it say? Is it the type you need? It should say this:

image

  • or the ForEach node outputs undesired type - note that the order in which you plug in wires into nodes may occasionally matter and the object type a node spits out on the other end will change. This macro is a good example.

Okay, this is what I get when I mouse over the Array input pin:
image

What I did to make the Array was to make the array on BP_BasicGameboard blueprint, and then assign the elements in the UI of the Level:
image

Now, the tiles in question are child objects of a parent class, so I should switch the Array type to be that of the parent class? Then I would be able to access that boolean within?

I meant the array variable itself. If it’s of the correct type, disconnect and reconnect the loop - it will inherit type from the var.

Sorry – is this what you meant?
image
So this means that it is the generic Actor type, then, correct? And I would need to change its type?

Exactly, ideally to the base parent class of whatever you want to hold inside. As in:

Yep! That was it! Thank you! I had tried changing the Array class before, but did not disconnect and reconnect; this worked!

1 Like

Yeah, any node with a grey wildcard pin will inherit type. You can also right click some pins to change their type.

1 Like