Unity 2D Game Development


Unity 2D Game Development
eBook: $14.99
Formats: PDF, PacktLib, ePub and Mobi formats
$12.75
save 15%!
Print + free eBook + free PacktLib access to the book: $39.98    Print cover: $24.99
$37.74
save 6%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Build a 2D game using the native 2D development support in Unity 4.3
  • Create a platformer with jumping, falling, enemies, and a final boss
  • Full of exciting challenges which will help you polish your game development skills

Book Details

Language : English
Paperback : 126 pages [ 235mm x 191mm ]
Release Date : March 2014
ISBN : 1849692564
ISBN 13 : 9781849692564
Author(s) : Dave Calabrese
Topics and Technologies : All Books, Game Development, Other


Table of Contents

Preface
Chapter 1: Introduction to the 2D World of Unity
Chapter 2: It Lives!
Chapter 3: No Longer Alone
Chapter 4: Give It Some Sugar
Chapter 5: The Ultimate Battle of Ultimate Destiny
Chapter 6: The Finishing Touches
Index
  • Chapter 2: It Lives!
    • Cameras – they now stalk us!
    • Falling to your doom!
    • Falling fatally into death colliders
    • Death and resurrection – respawning
    • Jump to it!
      • Jumping for fun (and profit)
    • Not missing the ground
    • Wait, did I collide with something?
    • Got a glitch?
    • Making the world bigger
    • Let's get dangerous
    • Bullets are better when they hit things
    • Summary

Dave Calabrese

Dave Calabrese is an independent professional video game developer who has worked in the industry since 2002. Starting as an intern and working his way up to running his own small studio, Cerulean Games, he strives to produce fun and quality entertainment while also inviting others to learn from his experience and mistakes. Dave has had the opportunity to work on branded projects for top names and produce titles for multiple platforms, including Xbox 360, iOS, PC, and Mac. Today, he continues to produce fun and original games, participate in game jams, and author books.

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 27 submitted: last submission 30 Jun 2014

Errata type: Code | Page number: 21

The first five lines of code shows:

Using Unity Engine;
Using System.Collections;
Public class PlayerStateController :MonoBehaviour
{
publicenumplayerStates

Should be:

using UnityEngine;
using System.Collections;
public class PlayerStateController : MonoBehaviour
{
public enum playerStates

Note: There are a few instances in the code of this book where you will find the above type of error. Please refer to the preceding solution.

Errata type: technical | Errata page: 12

The following paragrah:

With our platform made, let's make a hero. Back in the assets you downloaded
from the publisher's website, look for the folder labeled Player in the Animations
directory. Inside the Texture folder in your project, create a new folder called
Player and import the image named playerSpriteSheet.png to that folder.

should be:

With our platform made, let's make a hero. Back in the assets you downloaded from the publisher's website,
look for the folder labeled Player in the Art directory. Inside the Texture folder in your project,
create a new folder called Player and import the image named playerSpriteSheet.png to that folder.

Errata type: code | Errata page: 27

The code line: casePlayerStateController.playerStates.idle: should be: case PlayerStateController.playerStates.idle:

The code line: casePlayerStateController.playerStates.left: should be: case PlayerStateController.playerStates.left:

The code line: casePlayerStateController.playerStates.right: should be: case PlayerStateController.playerStates.right:

Errata page: 30

The code snippet should be:
using UnityEngine;
using System.Collections;
public classCameraController : MonoBehaviour
{
public PlayerStateController.playerStatescurrentPlayerState = PlayerStateController.playerStates.idle;
public GameObjectplayerObject = null;
public floatcameraTrackingSpeed = 0.2f;
private Vector3lastTargetPosition = Vector3.zero;
private Vector3currTargetPosition = Vector3.zero;
private floatcurrLerpDistance = 0.0f;

...and voidOnEnable() should be void OnEnable()

Errata page: 31

voidOnDisable() should be void OnDisable()
voidonPlayerStateChange(PlayerStateController.playerStatesnewState) should be void onPlayerStateChange(PlayerStateController.playerStatesnewState)
voidLateUpdate() should be void LateUpdate()
voidonStateCycle() should be void onStateCycle()
casePlayerStateController.playerStates.idle: should be case PlayerStateController.playerStates.idle:
casePlayerStateController.playerStates.left: should be case PlayerStateController.playerStates.left:

Continuous...


NOTE: In most of the code snippets that appear on this book, the first few lines that start with "using" has some errors. Please follow the casing and spacing provided in the code bundle as they are correct. Also, the lines starting with "case", "void", and more data types have the spaces missing; please follow the code bundle for the correct and updated version of code.


 

 

Errata type: Technical | Errata page: 8

The sentence under the heading The perspective camera: "A perspective camera (on the left in the following image) is Unity's
default camera. It shows the scene the way it actually is, just like our eyes see things.
Orthographic (on the right in the following image), on the other hand, completely
removes depth."

should be:

"A perspective camera (on the right in the following image) is Unity's
default camera. It shows the scene the way it actually is, just like our eyes see things.
Orthographic (on the left in the following image), on the other hand, completely
removes depth."

Errata type: Code

 

There are multiple instances of space errors in the code of the book. This has been changed in the latest version of the book.

Errata type: Technical | Page number: 13

 

Another option would be to go to the Slice menu (top left), leave Automatic as the Type option, change the pivot to Right

 

should be:

 

Another option would be to go to the Slice menu (top left), leave Automatic as the Type option, change the pivot to Bottom

 

Errata type: Technical | Page number: 49

 

The paragraph starting with "The most astute of you, while paying attention to the console, probably noticed an
error that keeps popping up"

 

should include one line before the starting statement. Thus, the paragraph should start with:

"Make sure that your Death Trigger object still has the DeathTrigger tag set. The most astute of you, while paying attention to the console, probably noticed an
error that keeps popping up"

 

Errata type: Technical | Page number: 57

 

X: 41, Y: 41

 

should be:


X: 0.42 Y: 0.41

 

 

Errata type: Code | Page number: 61

 

public EnemyControllerScriptenemyObject = null;

 

should be:

 

public EnemyControllerScript enemyObject = null;

Errata type: Technical | Page number: 57

 

Import the EnemySpritesheet.png file from the assets under Sprites\
Enemy\and then create a sprite sheet for the enemy as discussed earlier
in Chapter 1, Introduction to the 2D World of Unity.

 

should be:

 

Import the EnemySpritesheet.png file from the assets under Textures/Characters/ and then create a sprite sheet for the enemy as discussed earlier
in Chapter 1, Introduction to the 2D World of Unity.

Errata type: Technical | Page number: 57

 

Drag-and-drop the EnemyWalk_1 sprite into the Scene or the Hierarchy tab
to create the sprite in the world

 

should be:

Drag-and-drop the EnemyWalk_1 sprite into the Scene or the Hierarchy tab
to create the sprite in the world, and rename it to Enemy.

Errata type: Code | Page number: 66

 

public event hitByPlayerBullethitByBullet;

should be :

public event hitByPlayerBullet hitByBullet;

Errata type: Code | Page number: 68

 

At the end of the 2nd paragraph, the first line of code:


public ParticleSystemdeathFxParticlePrefab = null;

should be:


public GameObject deathFxParticlePrefab = null;

Errata type: Technical | Page number: 64

 

"Resize the Box Collider 2D..."


should be:


"Add a Box Collider 2D Component and resize it so that it is..."

Errata type: Code | Page number: 68

 

GameObjectdeathFxParticle =
(GameObject)Instantiate (deathFxParticlePrefab);

should be:


GameObject deathFxParticle =
(GameObject)Instantiate(deathFxParticlePrefab);

Errata type: Technical | Page number: 75

 

"Import the sprites from Sprites\ParallaxScenery"

 

should be:

 

"Import the sprites from Textures\ParallaxScenery"

Errata type: Technical | Page number: 81

 

Import the ones in the assets folder under Sprites\Vortex

 

should be:

 

Import the ones in the assets folder under Textures\Vortex

Errata type: Technical | Page number: 67

 

import the graphics from the folder Sprites\Particles

 

should be:

 


import the graphics from the folder Assets\Textures\Particles

Errata type: Technical | Page number: 87

 

Open the Graphics package you downloaded from Packt's site and find the boss' sprite sheet in Sprites\Boss and import it to the project.

 

should be:

 

Open the Graphics package you downloaded from Packt's site and find the boss' sprite sheet in Textures\Characters and import it to the project.

Errata type: Code | Page number: 92

 

// MovespeedMoveSpeed is positive here, causing the object to move upwards

 

should be:

 

// Movespeed is positive here, causing the object to move upwards

Errata type: Code | Page number: 92

 

MovespeedmoveSpeed * Time.deltaTime, 0f));

 

should be:

 

moveSpeed * Time.deltaTime, 0f));

 

 

Errata type: Technical | Page number: 97

 

The file path:

Sprites\Particles\Particle_Smoke.png

 

should be:


Assets\Textures\Particles\Particle_Smoke.png

Errata type: Code | Page number: 94

 

currentEvent = BossEventController.bossEventsinactive;

 

should be:

 


currentEvent = BossEventController.bossEvents.inactive;

Errata type: Technical | Page number: 102

 

In the Text Mesh field of the Roundobject, name its tag RoundWatcher.

 

should be:

 

Select the Round object, and change its tag to RoundWatcher.

Errata type: Technical | Page number: 104

 

Now for the start button! Add another empty GameObject, name it Start Button, and place it inside the Container – Startobject.

 

The above statement should be followed by:

 

Move the StartButton_Down and StartButton_Normal sprites to the project Hierarchy tab so that they become the children of the Start Button object.

Errata type: Technical | Page number: 12

 

Under the "Making new friends" heading

"Inside the Texture folder in your project, create a new folder called Player and import the image named playerSpriteSheet.png to that folder"

 

should be:

"Inside the Textures folder in your project, create a new folder called Characters and import the image named playerSpriteSheet.png to that folder"

Errata type: Code | Page number: 35

 

The following bit of code:

{
void OnTriggerEnter2D(Collider2DcollidedObject)
{
collidedObject.SendMessage("hitDeathTrigger");
}

}

 

should be:

 


void OnTriggerEnter2D(Collider2D collidedObject)
{
collidedObject.SendMessage("hitDeathTrigger");
}

}

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Unity 2D Game Development +    Social Media Mining with R =
50% Off
the second eBook
Price for both: $21.95

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Create a 2D game using Unity 4.3’s native 2D technologies
  • Control collisions using layered collision management
  • Manage events using basic timed sequencing – specifically, a boss battle
  • Discover how to track the score and game state
  • Design the development and deployment of state systems for object management
  • Use C# events and delegates to pass information between objects
  • Understand the usage of Unity’s tag system
  • Make 2D sprites make other 2D sprites explode with extreme prejudice

In Detail

Prepare yourself to travel back to the 90s and build a game like they used to make, using today's technology. That's right; we're talking about making 2D games using Unity!

This book will help you build 2D games in Unity using the engine's 2D technologies added in Version 4.3. You'll learn the basics of importing assets and building foundation technology all the way up to full combat and boss battles! With the book's straightforward and practical approach, each chapter takes you a step closer to the final game. We will wrap things up by looking into the basic aspects of the game's UI.

Once you reach the end and have integrated a final boss battle, you can go back to the challenges included in each chapter and use them to improve the game and your 2D game development skills!

Approach

A fun, easy-to-follow experience that takes you from an empty project in Unity 4.3+ all the way to a finished, functional 2D platformer, while giving you challenges and ideas to take what you learn in this book and expand upon it.

Who this book is for

This book is ideal for anyone who wants to learn how to build 2D video games or wants to expand their knowledge of the Unity game engine. To get the most from this book, having knowledge of C# and Unity is important, however, if you are less experienced in these areas, this book still gives you all the necessary tools to create your own game.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software