Game Development Reference
In-Depth Information
Note
There are many tools that can help you to create a sprite sheet, such as TexturePacker. It
basically creates an image file with the data that contains all the information such as name
of the sprite, position, and sprite area. In this process, we will have two files—the image
file (
.jpeg
or
.png
) and datafile (
.txt
or
.xml
)— which might be a bit confusing for
beginners. So, Unity 4.3 solved this problem by including the
Asset Import Setting
,
which we can just use to import the asset and set the
Texture Type
to
Sprite
, and then set
the mode to either
Multiple
(the image that contains many sprites packed in one file) or
Single
sprite.
For more information about TexturePacker and a sprite sheet, visit the following URL:
ht-
The purpose of this project is to familiarize you with the new 2D feature and language
syntax in Unity, which is very important when creating a playable game.
We will begin by setting up the sprite for our character, game level, and item in the game.
Next, we will create our character sprite object, create the animator controller, and set up
each animation clip for idle, walk, jump, and fall. We will also create the script, which
will control the character to show the correct animation (idle, walking, and jumping). This
script will allow us to control the character action by pressing the arrow key to move and
space bar to jump. Also, we will learn how to set up the custom input manager.
Next, we will create the level and platform using the sprite object with
BoxCollider2D
and
PolygonCollider2D
attached, which will collide with the character that has
Ri-
gidbody2D
attached to make the movement realistic.
To end the game, we will create a trigger event by having a door and key game object.
The player needs to collect the key to be able to open the door and end the game. We will
also add sound to make our game lively, but we are not finishing it yet. The game needs to
be replayable. Lastly, we will add a
Replay
or
Play again
button to replay our game by
using
Destroy
and
Instantiate
to reset our character's position and key item.