Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Unity 5.x 2D Game Development Blueprints
Unity 5.x 2D Game Development Blueprints

Unity 5.x 2D Game Development Blueprints: Explore the features of Unity 5 for 2D game development by building three amazing game projects

Arrow left icon
Profile Icon Abdelrahman Elsayegh Profile Icon Sapio
Arrow right icon
€17.99 €26.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7 (3 Ratings)
eBook Sep 2016 252 pages 1st Edition
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Abdelrahman Elsayegh Profile Icon Sapio
Arrow right icon
€17.99 €26.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7 (3 Ratings)
eBook Sep 2016 252 pages 1st Edition
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Unity 5.x 2D Game Development Blueprints

Chapter 2. Animations

Animating sprites is what makes them and the game come to life. Some 2D games are made just with static images by design. However, in our case, we will make animations and go through the process of animating 2D characters in Unity.

In this chapter, we will learn how to create and play animations for the player character to see as Unity controls the player and other elements in the game. This is what we will go through:

  • Animating sprites
  • Integrating animations into animators
  • Continuing our platform game

Animating sprites

Creating and using animations for sprites is a bit easier than other parts of the development stage. By using animations and tools to animate our game, we have the ability to breathe some life into it. Let's start by creating a running animation for our player. There are two ways of creating animations in Unity: automatic clip creation and manual clip creation.

Automatic clip creation

This is the recommended method for creating 2D animations. Here, Unity is able to create the entire animation for you with a single click.

If you navigate in the Project Panel to Platformer Pack | Player | p1_walk, you can find an animation sheet as a single file p1_walk.png and a folder of a PNG image for each frame of the animation. We will use the latter. The reason for this is because the single sprite sheet will not work perfectly as it is not optimized for Unity.

In the Project Panel, create a new folder and rename it as Animations. Then, select all the JPG images in Platformer Pack...

The Animator

In order to display an animation on a game object, you will be using both Animator Components and Animator Controllers. These two work hand in hand to control the animation of any animated object that you might have, and are described below:

  • Animator Controller uses a state-machine to manage the animation states and the transitions between one another, almost like a flow chart of animations.
  • Animator Component uses an Animator Controller to define which animation clips to use and applies them on the game object when needed. It also controls the blending and the transitions between them.

Let's start modifying our controller to make it right for our character animations. Click on the Player and then open the Animator window from Window | Animator. We should see something like this:

The Animator

Although it is automatically generated, this is a state machine. To move around the grid, hold the middle mouse button and drag around.

First, let's understand how all the different kinds of...

The game

In this chapter, the goal for our game is to apply the walk animation when the player is moving. Furthermore, we will prepare the jump animation for the next chapter. To achieve that, we need to set up the rest of the transitions.

In the Animator window, let's add a new transition from WalkAnim to Idle and name it StopWalking. Then, we need to add a condition that will trigger the transition. This transition will use the parameter PlayerSpeed so that when its value becomes less than one the transition is triggered.

The game

Now that the transitions between Idle and WalkAnim are ready, let's do the same to the JumpAnim state.

We need to make a transition from the Idle state to the JumpAnim state and vice-versa; we will name them StartJump and EndJump, respectively.

However, we are going to need another parameter to see if the player is currently jumping. We can do this by adding another parameter named Jump as a Boolean in the Animator window and set it to false.

This is what the...

Summary

This wraps up everything that we will cover in this chapter. So far, we have added animations to our character to be played according to the player controls. A brief summary of what we have discussed would be creating animations, animator controllers, state machines for Animation, and using animations in our game through the use of Scripts.

In the next chapter, we will make things even more realistic by using physics and applying it to our game.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore the 2D architecture of Unity 5, and the tools and techniques for developing 2D games
  • Discover how to use Unity’s 2D tools, including Sprites, physics, and maps, to create different genres of games
  • Practical tutorial on the intermediate and advanced development concepts in Unity 5 to create three interesting and fully functional games

Description

Flexible, powerful, and full of rich features, Unity 5 is the engine of choice for AAA 2D and 3D game development. With comprehensive support for over 20 different platforms, Unity boasts a host of great new functions for making 2D games. Learn how to leverage these new options into awesome 2D games by building three complete game projects with the Unity game tutorials in this hands-on book. Get started with a quick overview of the principle concepts and techniques needed for making 2D games with Unity, then dive straight in to practical development. Build your own version of Super Mario Brothers as you learn how to animate sprites, work with physics, and construct brilliant UIs in order to create a platformer game. Go on a quest to create a RPG game discovering NPC design, event triggers, and AI programming. Finally, put your skills to the test against a real challenge - designing and constructing a complex strategy game that will draw on and develop all your previously learned skills.

Who is this book for?

If you've got the basics of 2D development down, push your skills with the projects in this hands-on guide.Diversify your portfolio and learn the skills needed to build a range of awesome 2D game genres.

What you will learn

  • Explore and understand the vital role of sprites in 2D games
  • Move, animate, and integrate sprites into a 2D platform game
  • Set up User Interfaces (UIs) to keep track of the progress through the games
  • Apply 2D Physics to improve gameplay believability
  • Learn the foundation of Level Design and how to quickly create 2D Maps
  • Discover NPC design, event triggers, and AI programming
  • Create an epic strategy game, challenging all the skills acquired in the book

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 30, 2016
Length: 252 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396534
Vendor :
Unity Technologies
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Sep 30, 2016
Length: 252 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396534
Vendor :
Unity Technologies
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 111.97
Unity UI Cookbook
€41.99
Unity 5.x 2D Game Development Blueprints
€32.99
Getting Started with Unity 5.x 2D Game Development
€36.99
Total 111.97 Stars icon
Banner background image

Table of Contents

9 Chapters
1. Sprites Chevron down icon Chevron up icon
2. Animations Chevron down icon Chevron up icon
3. Physics Chevron down icon Chevron up icon
4. Level Design Chevron down icon Chevron up icon
5. Creating Our Own RPG Chevron down icon Chevron up icon
6. AI and Pathfinding Chevron down icon Chevron up icon
7. Tower Defense Basics Chevron down icon Chevron up icon
8. User Interface for the Tower Defense Game Chevron down icon Chevron up icon
9. Finishing the Tower Defense Game Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7
(3 Ratings)
5 star 33.3%
4 star 0%
3 star 0%
2 star 33.3%
1 star 33.3%
Bart Knowles Oct 27, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
You can ignore the negative reviews: they are clearly biased.This book is not perfect, yet it is one of the best on the market to learn how to develop games using Unity. I have a limited expewrience with Unity and I found it incredibly useful, with clear examples and step-by-step instructions.A couple of figures are too dark and some chapters are better written than others, but overall it is a must-have text.
Amazon Verified review Amazon
Overtech Oct 10, 2016
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I only worked through chapter 4 before returning this book. It's extremely basic and some of the code has errors or is outdated and simply won't work in the latest version of Unity (5.4 as of this book's publication). Ironically, it did help me learn more about Unity 2D game development because it often forced me to search for the correct answers online or figure them out myself. Unless you absolutely prefer a book format, you're better off finding 2D tutorials online.Despite my complaints, I did appreciate the fact that this was not an introduction to Unity book. The authors don't take time to explain things or spell things out, which was fine for me because I've read other books that walked me through the basics of Unity. If you're brand new to Unity, try a different book. I liked Unity in Action, but that's predominately 3D focused, which is why I was looking forward to this book. Unfortunately, this book didn't meet my needs, but I look forward to future 2D-focused books now that it is a standard feature in Unity.
Amazon Verified review Amazon
TJ Oct 16, 2016
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
This book was a disappointment at best. The book is very sloppy and very poorly edited. The authors leave out important steps, use wrong information, and even contradict themselves. For example in one section they tell you to rename an object Level, then you are to add children to this object, but as they continue to refer to the object they call it something else. It is only because they show a screenshot of what it is supposed to look like that the reader figures out what they really meant. This happens multiple times in the first few chapters.The coding in the book does not work properly. I had to go to outside sources to 'fix' the coding so that the project would work properly. They leave out very important information many times over. They have you add a script to make the player perform an action, however, they did not make sure the assets package they include is scaled the same as the asset you use for the player character. Implementing the script they tell you makes the player run around the screen and shrink in size. It is bizarre at best. This happens with several of their scripts in the beginning of the book. In addition, there are key components of the information that are outdated, again forcing the reader to go to outside sources to be able to complete the task.The sprites they give you to work with for your projects are sloppily made. When they 'cut' them on the spritesheet, they did not bother to make sure each image was cut straight so you get pieces of the other images in with each sprite. You cannot create a clean looking game with their materials. Trying to create a map with their assets just creates a huge mess.There were just so many things wrong with this book and that is just the first few chapters. It was such a disappointment.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.