33,59 €
Explore the features of Unity 5 for 2D game development by building three amazing game projects
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.
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.
This is a practical and easy-to-follow guide that starts with the basics and gradually delves into the process of creating 2D games. With step-by-step instructions on how to build three games, followed by a detailed explanation of each example, you will understand the concepts not just in theory, but also by applying the knowledge you gain in practice.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 165
Veröffentlichungsjahr: 2016
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2016
Production reference: 1230916
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78439-310-6
www.packtpub.comAuthors
Francesco Sapio
Abdelrahman Saher
Project Coordinator
Devanshi Doshi
Reviewers
Elizabeth Keegan
Melody Kaye Cariaga
Proofreader
Safis Editing
Acquisition Editor
Larissa Pinto
Indexer
Mariammal Chettiyar
Content Development Editor
Shali Deeraj
Graphics
Disha Haria
Technical Editor
Sachit Bedi
Production Coordinator
Arvindkumar Gupta
Copy Editor
Safis Editing
Francesco Sapio obtained his computer science and control engineering degree from Sapienza University of Rome, Italy, a couple of semesters in advance, scoring summa cum laude. Now, he is studying a master of science in engineering in artificial intelligence and robotics.
He is a Unity3D and Unreal expert, a skilled game designer, and an experienced user of the major graphics programs.
Recently, he authored the book Unity UI Cookbook (Packt Publishing) which teaches readers how to develop exciting and practical user interfaces for games within Unity, and a short e-guide What you need to know about Unity (Packt Publishing). Furthermore, he has also been a reviewer for the following books: Unity Game Development Scripting (Packt Publishing) and Unity 5.x by Example (Packt Publishing).
Francesco is also a musician and a composer, especially of soundtracks for short films and video games. For several years, he worked as an actor and dancer. He was a guest of honor at the theater Brancaccio in Rome.
In addition, he is a very active person, having volunteered as a children's entertainer at the Associazione Culturale Torraccia in Rome. He also gives private lessons in mathematics and music to high school and university students.
Finally, Francesco loves math, philosophy, logic, and puzzle solving, but most of all, creating video games, thanks to his passion for game designing and programming.
You can find him at www.francescosapio.com
I'm deeply thankful to my parents for their infinite patience, enthusiasm, and support throughout my life. Moreover, I'm thankful to the rest of my family, in particular my grandparents, since they always encouraged me to do better in my life with the Latin expressions "ad maiora" and "per aspera ad astra." Finally, a huge thanks to all the special people around me whom I love, in particular to my girlfriend; I'm grateful for all your help in everything.
Abdelrahman Saher graduated with a BSc in Computer Science in 2012. After graduation, he worked for the video game company EverylPlays, where he participated in the programming of a couple of mobile games. Later, in 2013, he moved into the challenging role of lead programmer with the video game company Appslnnovate. Apart from his full-time job, Abdelrahman recently started his own start-up video game company called Robonite.
Elizabeth Keegan is a practitioner in the field of game design and art. She obtained her bachelors degree from Cleveland's very own Institute of Art and masters degree from UC Berkeley in Fine Art. Currently, she's heading the continued growth of the Game Design program at Notre Dame College. Game design has been her primary focus for many years and spans a range of disciplines. She has worked both collaboratively and independently on many projects concerning topics such as Artificial Intelligence, Air Pollution, Autism, and Mental Therapy. More importantly, Elizabeth has taught across a range of age groups and classrooms. She has worked alongside high school students in summer camps, 9th grade year, round programs, and college classrooms. All of these experiences have taught her the power of game development and its ability to facilitate critical thinking and creative problem solving among many other crucial skills in today’s workplace.
She is the current a game design instructor at Notre Dame College in South Euclid, Ohio, and has worked alongside Rachel Morris who is the head of the art department.
I would like to thank both Abdelrahman Saher and Francesco Sapio,for providing yet another accessible resource to those interested in game development. I would also like to thank Sanchita Mandal and Paushali Desai for including me in the review process.
Melody Kaye Cariaga graduated from De La Salle College of St. Benilde with a BS in Information Technology and a specialization in game design and development. This program was a first in the Philippines; on February 2013, she was a part of the very first batch of graduates with the title of cum laude under her name.
Since February 2013, she has been working as a game developer. On her first job, she developed HTML5 games for three major American cable and satellite television networks aimed mainly at the child and adolescent demographic. In May 2015, she started working for Xurpas Inc., the first tech startup in Southeast Asia to go on initial public offering, as one of their Unity developers that create Android games.
Melody is a strong, hardworking woman, who always aims to do better and be better in life. She is a well-organized individual who never fails to give more than 100% in her work and never loses sight of her goal. Even though she is driven, she still has time to enjoy playing games, listening to music, and watching movies. She never loses sight of who she really is.
For all the success and achievements I have received throughout my career, I would like to thank God Almighty for His everlasting grace, my family for their never-ending guidance and support, and my special someone for his trust in everything I do.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.packtpub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
In this book, there are three projects presented: a Platformer game, an RPG-style game, and a Tower Defense game. Their purpose is to teach you Unity 2D game development with a practical approach.
Chapter 1, Sprites, introduces the reader to the basic elements of 2D game development in Unity, Sprites. Furthermore, it gets the reader to start building the platform game.
Chapter 2, Animations, explains how to animate a Sprite in Unity and how to trigger different animations depending on the state of the character.
Chapter 3, Physics, teaches how to deal with 2D physics in Unity and how to use it to achieve believable movements.
Chapter 4, Level Design, introduces the reader to the Tiled Map Editor by showing the workflow from the creation of the map, and how to import it into Unity. Furthermore, it concludes the platform game.
Chapter 5, Creating Our Own RPG, starts with the foundations for creating the RPG game, by explaining the basic concepts needed for it.
Chapter 6, AI and Pathfinding, introduces the reader to basic Artificial Intelligence techniques, such as Pathfinding, and completes the RPG game.
Chapter 7, Tower Defense Basics, explains the basics for the creation of a Tower Defense game, using all the concepts learned so far.
Chapter 8, User Interface for the Tower Defense Game, dives into more in detail about creating a user interface for your games, with particular focus on the Tower Defense game.
Chapter 9, Finishing Tower Defense Game, wraps everything up and completes the Tower Defense game by explaining gameplay elements and how to make all the elements of before they interact with each other.
For this book, you will need Unity 5.x and Tiled Map Editor 0.16.1.
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 to build a range of awesome 2D games in different genres.
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.
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.
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:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Unity-5x-2D-Game-Development-Blueprints. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
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/Unity5x2DGameDevelopmentBlueprints_ColorImages.pdf.
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 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.
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.
As we start our journey into the world of 2D game development, let's start this chapter by talking about the most important elements of creating 2D games. A 2D sprite is a two-dimensional image that is rendered on your screen while the game is still running.
In this chapter, we will start working on our own Platformer game. It consists of a character that must navigate through a platform level by jumping and running to achieve certain tasks. Along the way, we will learn how to use sprites and how Unity handles them. In this particular chapter, we will cover:
Unity has a 2D mode that allows us to quickly set up the project for 2D game development. In fact, the main reason to use this mode is to automatically import new assets as Sprites.
When creating a new project, you have the option to choose between the 3D and the 2D mode. Let's select the 2D mode, as shown in the following image:
Now, we need to import the standard assets that we will use to build our game. Click on Asset packages and select 2D.
Unity doesn't come with the standard packages, you need to download them from the official website.
Finally, we can click on Create project. If you have used Unity before for 3D game development, you will notice a few differences in the default interface. In particular, the 2D view is already selected:
Furthermore, the camera in new scenes will always be orthographic, which is exactly what we want:
Having selected the 2D mode doesn't mean that you cannot change it any more. In fact, you can change it to 3D mode whenever you want by going to Edit | Project Settings | Editor and selecting 3D under Default Behavior Mode.
This can come in handy when adding 3D models to your 2D project and vice versa. It is recommended that you switch before importing 2D sprites or 3D models to the appropriate mode since Unity will import textures accordingly.
During the course of this book, we will use custom packages, since we don't have time to create all the graphics on our own.
For our first game, we are going to use a package from http://kenney.nl