• News

• Industries

• Learning & Support

• Community

• Marketplace

# Looking for a type of "value" that can hold multiple "0 / 1" or something similar

Hi !

I need to explain myself a bit because I am not really sure what I am looking for, my apologies…

So I was in the need of comparing 4 booleans - in this specific example I had to check how many neighbours something had and what kind of neighbours those were (Top Right Bot Left)
Each possible combination of this had a specific outcome. So all together they were 15 or so possible combinations.
I didnt want to create branch after branch after branch to get to the outcome.

So what I did was creating a COLOR value, since LUCKILY it stores 4 values (RGBA) for my 4 Neighbours. So If TOP was true I set R=1 else=0
So If there was a TOP and RIGHT Neighbour the color would be 1 1 0 0
Then I had a COLOR ARRAY that I manually filled with all possible outcomes. I searched through it to find the equal one and the outcome of the array was the index of the specific result …

Works perfectly fine in this case (even tho I feel guilty and wrong) but of course I am screwed if next time I have to set 5 or more true/false values in one row of an array.

Do you guys have a proper value for me? Are values wrong here and I should use something else? Datatablethingy or enum strukturethingy or something? A little guidance would be much appreciated

Thanks a lot!

BR
Sven

why dont you just use an array of bools?

Because I would need multiple 0/1 in a single line/index of an array.

well a boolean is a 1/0. u can think of 1 being true and 0 being false

What you want is an array of arrays, which Unreal doesn’t support very well (blueprint or native).

What you can do is create a new structure:

This you can configure very similar to Blueprint variables, so you’d set it up with an Array of bools. Then in your Blueprint you’d create an array of that structure that you created.

The only downside to this approach is that you can no longer easily do the same “Value equals 1100” sort of trick that you’re using to avoid the all the branching. But that’s the sort of trade-off you may just have to decide which is more important.

Alternatively you could give that structure 4 bools named Top/Bottom/Left/Right instead of the array. The equals check might work in this case, but you wouldn’t have the ability to hold an arbitrary number of values. From your description that might be okay since if you needed it you could edit the structure definition, something you wouldn’t be able to do with COLOR.

You could also try using an integer and doing manual bit manipulation, but that may be more advanced/complicated than you would like.

1 Like