# Creating a pipe game using blueprints

I want to make a pipe game mini game in the game I am working on. I’m still pretty new at unreal and blueprints and have no idea how to do this.

So far I have the “pipes” (cubes with textures to show directions) spinning the way I want and you can complete the puzzle, but the game doesn’t know that.

Here’s how I have the cubes spinning

I named the cubes cubeA-cubeP going from left to right, top to bottom.

cubeD(top right) is where it starts and cubeM(bottom left) is where you want to end up.

For ease, I want to have the air(these are air vents) to want to always or at least automatically flow straight i.e. flowing from cubeG left to cubeF it would go straight to cubeE if it could go into cubeE which it can’t in that picture, but you should get what I mean.

HERE is where I am now.

Ok, so I pretty much figured out how to do the arrays of everything, except it isn’t possible with blueprints and I’m not sure how to go back and forth between blueprints and c++, also my team has decided to do everything in blueprints.
I have an array of 16 actors and each of the actors has the component variables which are booleans: Left,Down,Right,Up,Flow
But the problem with this is each time I reference one of the booleans it has to be specific to what object it is from. Like I want to check if the Up is true for the 7th node(the one below the starting node,) I would have to use cubeH_Blueprint’s Up and I can’t do things in general. This would force me to actually code out every possible path which would be ■■■■■■■ ridiculous.
So I can’t have an array of arrays and I can’t easily access each boolean from each member of the array of objects easily. What can I do?
The algorithm I want to use goes something like this.

``````curNode = 3
if curNode.Left{
curNode -=1
ifCurnode.right{
set curNode.flow = true;
if curNode.left{
curNode-=1...
}
if curNode.down{
curNode +=4...
}
if curNode.Up{
curNode -+4...
}
}
}
else if curNode.Down{

}
``````

There are several ways to solve this, so I’m just going to recommend one possible approach. Instead of using 4 booleans, use one enumeration which has EUp, EDown, ELeft, ERight describing all the possible directions. “If” you were using C++, I’d recommend using an ALevelScriptActor and a UDataAsset for this next part. However, since you’re not…you’re going to have to handle this in a GameMode blueprint and derive it for each level. Create a GameMode blueprint that has 3 arrays that are 16 in length. One filled with the actors, one filled with their starting directions and one filled with their required directions. Setup the GameMode to spawn the actors in their starting directions on BeginPlay. “For Each Level” derive from this class and input the required values. As to how you handle the “Level Completion,” you can either have the GameMode tick every frame (less efficient) and check if the values are right or you can call an “Update” method every time you rotate a pipe. Hope this helps.

Thank you I’ll keep you posted if we run into any more issues implementing it.