Game Development Reference
In-Depth Information
7. The last step is to tag the
Brick
instances as
BarrierBrick
and to flag
the
Is Trigger
option on their
Box Collider
component so that they can be
affected by the collisions with both the player's and aliens' bullets. You should
remember how to create a new tag and how to assign it to a prefab, but in
case you don't remember, please refer the following screenshot:
Now test your game. Both the player's and aliens' bullets should destroy a piece of
the barriers upon collision.
The player's ship reprise
We need to go back to the player's ship to prevent it from moving outside of the game
area boundaries. This is easy to achieve. We simply add an
X
coordinate position
check of the ship itself before allowing the player to move left or right.
Modify the
Update()
function in the
ControlShip
script as shown in the following
code: