Game Development Reference
In-Depth Information
2. Next, we create another material for our door; go to
Assets
|
Create
|
Material
,
name it
M_Door
, and set the following:
Shader
:
Diffuse
Main Color
:
R: 219
,
G: 255
,
B: 255
,
A: 255
Base (RGB
)
Drag-and-drop our
doorClose.png
in the
Graphics/Level
to the
texture thumbnail in the material inspector
3. Before we create our mesh object, we have to create a new
Tag
for our
Door
and
Key
, so go to
Edit
|
Project Settings
|
Tags
.
4. Under the
Element 3
type
Door
, and under
Element 4
type
Key
. Now, we will create
a key object by using a plane in Unity; it's very similar to our
Player
. So, go to the
Plane
prefab object in the
FBX
folder and drag it into the
Hierarchy
view.
5. In the
Hierarchy
view, right-click on the
Plane
prefab object, and choose
Rename
to
change the name to
Key
.
6. Next, right-click on the
Animation
component in the
Inspector
view and choose the
Remove Component
opion to remove it. We will see the pop-up window, so just
click on the
Continue
buton similar to how we did for our
Player
object.
7. Click on this object and go to its
Inspector
view, and set the following:
Tag
:
Key
Position
:
x: 21
,
y: 7.5
,
z: 0
Rotation
:
x: 0
,
y: 180
,
z: 0
Scale
:
x: 2.75
,
y: 2.75
,
z: 2.75
8. Assign our
M_Key
to this material. Then add the
Box Collider
to the
Key
as we
did for our
Player
; go to
Component
|
Physics
|
Box Collider
set
Size: x: 1
,
y: 1
,
z: 1
and
Center: x: 0
,
y: 0
,
z: 0
, and toggle
Is Trigger
to
true
.
9. Copy the
Key
by pressing
Command + D
or
Control + D
to create the
Door
object.
Then, we name it
Door
, assign material
M_Door
to it, and set the following:
Tag
:
Door
Position
:
x: 19.5
,
y: 16
,
z:
0
Rotation
:
x: 0
,
y: 180
,
z: 0
Scale
:
x: 7.5
,
y: 7.5
,
z:
1