Game Development Reference
In-Depth Information
Creating a rockslide and trigger area
In the last secion we created the destrucible wall object, which contains four cubes, each
with the
Rigidbody
and
Box Collider
atached to it, and we can shoot to break it.
In this last secion, we will create the rockslide that the rock will fall on when the player hits
the trigger area and creates the
Rocks
and
TriggerArea
script to enable and disable the
Rockslide
object.
Prepare for Lift Off
Go to
GameObject
|
Create Empty
to create the empty game object and name it
Rockslide
and reset its posiion to
X: 0
,
Y: 0
,
Z: 0
.
Then, create another empty game object by going to
GameObject
|
Create Empty
; name it
Break
and drag it inside the
Rockslide
, as shown in the following screenshot:
Next, create two cube objects, which will be the staic object to make it look like some part
of the rock is sill stuck to the terrain, and the trigger area to make the rock fall down when
the player hits it. Before we start, we need to reset the
Transform
of the
Break
game object
to default by clicking on the litle gear on the right-hand side and then choose
Reset
.
Engage Thrusters
We will start by creaing eight cubes to represent the rock pieces that will fall down:
1. Let's go to
GameObject
|
Create Other
|
Cube
, name it
Cube1
, and drag it inside
the
Break
game object inside
Rockslide
, which we just created.
2. Then, we will add the
Rigidbody
to the
Cube1
by going to
Component
|
Physics
|
Rigidbody
.
3. Next, we will go to the cube
Inspector
view to set up the parameters as follows:
F
Transform
Position
:
X: -1.5
Y: 0
Z: 0
Rotation
:
X: 0
Y: 0
Z: 0
Scale
:
X: 3
Y: 3
Z: 5