Part 8 — Build the brick field
In this part, we will add the bricks the player needs to break.
We will focus on layout first. In the next part, we will add the script that turns a collision into points and progress.
Create a Bricks Parent
Create an empty GameObject called Bricks.
This parent keeps the level layout tidy. It does not need a renderer, collider, or script.
Create One Brick
Create a rectangle primitive and rename it Brick.
Add or confirm these components:
Rectangle RendererBoxCollider2D
Set the GameObject tag to Brick.
Make the brick wide and short. Place it near the top of the play area.
Save a Brick Prefab
Save the brick as a prefab under:
Assets/Prefabs/
A prefab gives you one reusable source for all the bricks. If you later change the brick size or default components, you can update the prefab instead of rebuilding each brick by hand.
Build Four Rows
Under Bricks, create four row parents:
Row 1
Row 2
Row 3
Row 4
Duplicate the brick prefab eight times under each row.
Use this visual order from bottom to top:
- Row 1: yellow
- Row 2: green
- Row 3: orange
- Row 4: red
At this point, setting the color in the Inspector is enough. The next part will add scoring data to the bricks.
Test the Ball Against Bricks
Press Play and launch the ball.
The ball should collide with bricks, but the bricks should not disappear yet. That is expected. So far, they are physical objects, not gameplay objects.
Tip: This is a useful checkpoint. If the ball does not collide with the bricks now, fix the colliders before adding brick scripts.
Checkpoint
At the end of this part, you should have:
- a
Bricksparent - four row parents
- eight bricks per row
- visible brick colors
- a
BoxCollider2Don every brick - every brick tagged
Brick
Next, we will break bricks and score points.