Strange logical error with Array

There’s an extremely strange bug that I’m encountering.

It seems that either EQUAL node is bugging out or Contain Node is bugged out. OR Array’s data is messed up. Or I’m really seeing things.

After hours of trying to solve this, I simplify problem.
setup is very simple. If this array contains item X , then loop through array to find item X.

Now here are strange things that are happening.
How did Array pass conditions of contain when array shown on rigth obviously shows a NONE.
And if it passes contain conditions, how did it then proceed and loop through all without getting it.

Even if it’s first condition bugged out. loop went through a second iteration and problem repeated itself.
Is there anything that’s causing this in particular?

I would like to add that this is potentially a similar issue with

It is POSSIBLE that :

While array shows none. It actually contains value that passes through the ‘Contains’ condition but does not work well when it’s being ‘GET’

This thread is about adding something that doesn’t work. Your problem is about not adding something but array seems to contain something.

Have you already Printed everything to see where issue comes from?
If not, please put print nodes infront of first branch, printing Contains result, and a print node behind for loop, printing name of every element of array loop runs through.

So we get a look at where issue is accuring from. Are you sure, you never filled anything inside that array?

Not really… in my scenario. Arrays are filled. I’m using it to check if it contains ‘self’ ( Owner ) .

And then I’m using it to cycle through Array to see where ( which Index ) owner is.

In picture… in red Box that I outlined as “3)” … reason why I’m “why should this ever run” is because if Array already contain Item. Why would manually looping through array fail to find item.

So far, I did manage to to print out object one by one. I noticed a major issue, ForEachloop function, Array Element is returning as NOTHING. However if you manually ‘Get’ item from array, objects are there.

Ok, so array elements of For Each Loop return as Null. That’s weird.

Is it possible to use the “Find” node for array? It searches array for an element and returns it’s index.

I don’t know why for each loop is messing here, but maybe that solves your issue.

Find seems to work. But it seems like double work. I’ll have to use that for now.

Hey Frozenfire,

I’m looking into this issue now and seeing some different behavior. It looks like Contains node isn’t detecting a reference to Self, even though my actor is in array. But I do not see any issue with ForEachLoop returning null.

If you can recreate this issue in a new small project and that up for me, I can take a closer look. In meantime, I will continue to look into whether Contains node is working as intended. Thanks!

Hi ,

How did you manage to re-create issue?

Btw, I’ve moved on to another implementation without this particular structure of array. It has been so long. I WAS pretty sure in my particular implementation issue is in ForEachLoop but to be honest I have completely forgotton, there was so many issues jumbled up I have no idea where to begin to approach solution.

If anything like this pop up again, I will package them up immediately. I did discover however that Find and Contain sometimes return different result.

I created an array from Actor Blueprint instances in level and then cast to that array on a click. It does a Contains check, which always returns false. I believe Self node is not actually returning a reference to instance in level, but I’ll need to look into that further. It may be that problems you saw were related to Reference to Self node.

If you do run into a similar problem again, please let us know. I’ll mark this as resolved until then. Thanks!