Game Development Reference
In-Depth Information
13. We can see that we already have the
Platform_1
and
Platform_3
prefab. Now,
we will create the
Platform_2
prefab from scratch. First, we will go to
Sim-
plePlatform
|
Resources
|
Sprites
|
Level
in the
Project
view and click on the ar-
row in front of the
Platform
file. Then, we will click on the
Platform_2
object
and drag it inside the
Level
game object in the
Hierarchy
view. Click on this ob-
ject and add
Polygon Collider 2D
by going to
Component
|
Physics2D
|
Poly-
gon Collider 2D
. Then, we will go to
Inspector
and set the values of the attrib-
utes as follows:
Tag
Ground
Layer
Ground
Transform
Position
X
:
-7
,
Y
:
-1.17
, and
Z
:
0
Box Collider 2D
Material
Ground
(drag the Physics2D Material here)
14. Now, we go to the
Scene
view. We will see that our
Platform_2
sprite has
Poly-
gon Collider 2D
that matches the shape of this sprite, as shown in the following
screenshot: