Book Image

Getting Started with Unity 5.x 2D Game Development

By : Francesco Sapio
Book Image

Getting Started with Unity 5.x 2D Game Development

By: Francesco Sapio

Overview of this book

Want to get started in the world of 2D game development with Unity? This book will take your hand and guide you through this amazing journey to let you know exactly what you need to build the games you want to build, without sacrificing quality. You will build a solid understanding of Unity 5.x, by focusing with the embedded tools to develop 2D games. In learning about these, along with accurate explanations and practical examples, you will design, develop, learn how to market and publish a delectable Tower Defense game about cupcakes versus pandas. Each chapter in this book is structured to give you a full understanding on a specific aspect of the workflow pipeline. Each of these aspects are essential for developing games in Unity. In a step-by-step approach, you will learn about each of the following phases: Game Design, Asset Importing, Scripting, User Interfaces, Animations, Physics, Artificial Intelligence, Gameplay Programming, Polishing and Improving, Marketing, Publishing and much more. This book provides you with exercises and homework at the end of each chapter so that you can level up your skills as a Unity game developer. In addition, each of these parts are centered on a common point of discussion with other learners just like you. Therefore, by sharing your ideas with other people you will not only develop your skills but you will also build a network.
Table of Contents (16 chapters)
Getting Started with Unity 5.x 2D Game Development
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Preface

When Packt asked me to write this book, we had in mind something more modest than the book that you have today. While I was writing, I realized how many books can be found on the shelves that teach the basics without giving any practical insight on how to use that knowledge to actually make a game. Therefore, I slightly deviated the course of this book. As a result, it has changed into a somewhat solid manual about Unity, with a particular focus on 2D game development. The book that you are holding in your hands (either hard copy or on your tablet) is the outcome of a lot of effort trying to create something that is easy for the readers to understand, without sacrificing completeness or practical use of the different tools learned. Thus, everything is explained in detail, along with many examples of usage.

Also, I felt that another big deficiency of many books is the lack of Homework sections that provide the reader with exercises to improve her/his skills. In fact, I believe that these sections are important, since they provide a common ground in case you want to challenge yourself and take the discussion beyond the book with your friends, course mates, or colleagues. In the field of game development, it's important to collaborate, because a game is often the result of the coordinate efforts of many talented and passionate people.

For this book, I decided to support the learning of the different tools we will face by building a tower defense game on the joyful and sugary theme of cupcakes, sprinkles, and sweet-toothed pandas who will try to bite the delicious player's cake. This project will guide the reader through the book, and help her/him to develop a practical skillset as well.

Whoever you are, a hungry student of knowledge, a professor looking for a book to adopt in your classes, an expert in game development trying out Unity (or willing to extend your understanding of Unity), or just a passionate hobbyist, I hope you will enjoy this book.

What this book covers

Chapter 1A Flat World in Unity, is an introduction to the 2D world of Unity. You will discover how to set up your project, import assets, and make them ready to use. In particular, we will go through in detail on how to use the Sprite Editor.

Chapter 2, Baking Cupcake Towers, teaches you how to integrate code within your game. We will cover the important and fundamental concepts of Unity and we will see how to script game objects by starting to create the behaviors of our cupcake towers for the tower defense game we are building.

Chapter 3Communicating with the Player – the User Interface, deals with the important task to provide feedback to your players through the use of user interfaces (UIs). You will learn how to design them by discovering the general principles behind them, and learn how to implement any UI within the UI system of Unity.

Chapter 4No Longer Alone – Sweet-Toothed Pandas Strike, introduces us to the terrible sweet-toothed Pandas, who will try to steal the player's cake. You will learn how to bring characters to life by using the powerful animation system of Unity Mechanim, starting from Sprite-sheets.

Chapter 5The Secret Ingredient Is a Dash of Physics, takes you by hand deep down into the secrets of physics and explains them in a clear and easy way. You will grasp the basics of physics, and learn how to use the 2D Physics engine of Unity.

Chapter 6Through a Sea of Sprinkles – Navigation in Artificial Intelligence, is an introduction to the universe of artificial intelligence applied to video games. You will learn the basics principles and how to implement a navigation system in Unity for 2D (or even 3D) games, so that we can make our terrible sweet-toothed Pandas move!

Chapter 7Trading Cupcakes and the Ultimate Battle for the Cake – Gameplay Programming, wraps everything we saw and learned in the previous chapters to conclude the tower defense game. In particular, we will deal with gameplay programming, which is the glue between the different parts of your game.

Chapter 8, What Is beyond the Cake?, explores different aspects of our game and game development in general. You will discover different tips, tricks, and suggestions on how to improve the game we built in this book, along with improving your own skills to become a better game developer. Then, the chapter will give you an understanding of parts of the game development pipeline, which are not strictly tied to the development of the game itself. Thus, you will dive into different topics ranging from playtesting, optimizations, team management and work, documentation, getting ready to publish your game, marketing, social media, game protections, to even localization.

What you need for this book

To go through the topics covered in this book, you will need two important things:

  • Any version of Unity, possibly 5.x since it was the range of versions that this book has been written for. As you already know, and Chapter 1, A Flat World in Unity, will repeat, you can get it from the Unity official website: http://www.unity3d.com.

  • Your enthusiasm and passion, in order to take an awesome journey in the world of game development together!

Who this book is for

Anyone including students, game enthusiasts, and academic professors who want to adopt this book as part of their course and classes. 

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "All of them are placed inside a folder named Assets, which can be found inside the Project folder."

A block of code is set as follows:

public AwesomeUnityDeveloper GettingStarted(Yourself you) {
  you.ReadThisBook();
  return you;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public AwesomeUnityDeveloper GettingStarted(Yourself you) {
  you.ReadThisBook();
  return you;
}

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "First of all, if you ever need to switch between 2D and 3D mode, you can do so by navigating to Edit | Project Settings | Editor."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Getting-Started-with-Unity-5.x-2D-Game-Development. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/GettingStartedwithUnity5x2DGameDevelopment_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.