Q: Will this BP produce the desired result as the C++ code

I have a generation BP that is essentially creating a rough layout for a randomly generated map. Above is the segment of code I’m experiencing problems with. It doesn’t appear to be working like the C++ code I’m converting from.

The line of code that I’m working with is simply:
Tiles[tileIndex].directionsAvailable |= NORTH;

Is there a better way? I’m running into problems with the way the directionsAvailable is being set in the BP. My C++ code works just great and is very compact. I may end up being forced to mix BP and C++, but was hoping to stay with BP if at all possible.

‘directionsAvailable’ is an integer that is being used as the container for my bitflags (NORTH=8, EAST=4, SOUTH=2, WEST=1).

Thanks!

Nobody will able to solve the problem is you don’t tell what “problems you running in to”. For me it looks correct, it should add “North” bit in to “Directions Available”, maybe there a problem with the flow? You sure NORTH is set to 8 at that moment?

Alternaticly you could make struct of bools insted, i don’t see flags being used in UE4 community and in engine i only seen them being used for UObject and reflection system features.

Extra pro tip: You dont need to use break and make nodes, you can break struct pins by right clicking them and there will be “Split” option, ofcorse it does not have hide option like Break and Make so it depends on you.

Thanks! Don’t really need a solution to the problem itself, per se, but just needed confirmation that the above BP is the correct (though apparently long handed) way to translate my code so I can more confidently troubleshoot elsewhere. :slight_smile:

Thought about doing the bools in the structure individually, but it’s so much more convenient and compact to work with the bitflags.

Also, thanks for the tip! I really appreciate that. Any shortcuts are greatly appreciated.

I tried to when I wrote that, but didn’t have the answer icon. It’s there now. :slight_smile:

Ok i convert to anwser then :slight_smile: