# Hexagon Sections

• I'm attempting to create my own hexagon based grid for testing. I've been able to assemble hexagons the way I want and now I'm trying to have separate sections for each hexagon. Here's a pic of what I'm trying to accomplish.

How do I setup the hexagon so that each of the 6 equal triangles appear to fit inside the hexagon together equally? You can easily place the 6 triangles on the hexagon and they fit. I'm just not sure what events would place them all together so that every hexagon on the layout has the 6 triangles. Each triangle is a separate sprite.

Also, is it possible to randomly have each hexagon get a random arrangement of the 6 triangles? Any help would be appreciated.

• Put the origin point at a tip of the triangle.

For each hexagon x/y

Repeat 6 times - Spawn triangle at x/y, rotate loopindex*60 degrees.

To get a random color for each triangle, assuming you are using a single object with different animation frames, add an action to set animation frame to floor(random(6)).

To get a non-repeating random color for each triangle, create an array size 0,1,1.

Step 1 - Populate the array

Repeat 6 times - Array Push Back loopindex

Step 2 - Pick a number out of the array out of the remaining available numbers (use a variable)

Set PickedIndexVariable to floor(random(array.width))

Step 3 - Apply the picked number

Set triangle animation frame to Array.At(PickedIndexVariable)

Step 4 - Delete the picked index so it can't be picked again

Array delete index at PickedIndexVariable

Repeat steps 2-4 until all numbers are picked

Repeat step 1 for next set of triangles.

Repopulate array

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Put the origin point at a tip of the triangle.

For each hexagon x/y

Repeat 6 times - Spawn triangle at x/y, rotate loopindex*60 degrees.

To get a random color for each triangle, assuming you are using a single object with different animation frames, add an action to set animation frame to floor(random(6)).

To get a non-repeating random color for each triangle, create an array size 0,1,1.

Step 1 - Populate the array

Repeat 6 times - Array Push Back loopindex

Step 2 - Pick a number out of the array out of the remaining available numbers (use a variable)

Set PickedIndexVariable to floor(random(array.width))

Step 3 - Apply the picked number

Set triangle animation frame to Array.At(PickedIndexVariable)

Step 4 - Delete the picked index so it can't be picked again

Array delete index at PickedIndexVariable

Repeat steps 2-4 until all numbers are picked

Repeat step 1 for next set of triangles.

Repopulate array

Well that first suggestion actually worked. The triangles are a little uneven but I guess I have to create a better triangle. Thanks again.