Unity 5.x 2D Game Development Blueprints - Francesco Sapio - E-Book

Unity 5.x 2D Game Development Blueprints E-Book

Francesco Sapio

0,0
33,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Explore the features of Unity 5 for 2D game development by building three amazing game projects

About This Book

  • 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

Who This Book Is 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

In Detail

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.

Style and approach

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:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 165

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Unity 5.x 2D Game Development Blueprints
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Sprites
2D mode
Custom packages
Dealing with sprites
Importing sprites
The Sprite Renderer component
The Sprite Editor
Our character makes its first steps
Summary
2. Animations
Animating sprites
Automatic clip creation
Manual clip creation
The Animator
The game
Summary
3. Physics
2D physics
Rigid bodies
Colliders 2D
Box Collider 2D
Letting the character move
Adjusting the Platformer 2D controller
Defining a physical shape for the character
Improving the Animator
Testing the character movement
Building a cool level
Summary
4. Level Design
Tiled for 2D level design
Approaching UI
Game handler
Adding enemies
Summary
5. Creating Our Own RPG
Role-Playing Games
Getting ready
Importing the level
Slicing the sprites for our hero
Creating our hero
Dressing up our hero
Giving the power of movement to our hero
Animating the hero
Summary
6. AI and Pathfinding
Pathfinding
AStar Algorithm in Unity
A tool for Unity
Setting up the tool
Using pathfinding for enemies
Shaping our soldier
Giving intelligence to the soldier
Final notes
Summary
7. Tower Defense Basics
Tower Defense games
Getting ready
Setting up the scene and creating the map
Bullets
Creating the bullet prefab
Scripting the bullet
Towers
Creating the tower prefab
Scripting the towers
Enemies
Creating the enemy prefab
Scripting the enemies
Moving along the designed path
Detecting towers' bullets
Summary
8. User Interface for the Tower Defense Game
Getting ready
Designing the UI
Creating a lives counter
Creating and placing the lives counter
Scripting the lives counter
Implementing a money system
Creating and placing the money counter
Scripting the money counter
The tower seller
Creating and placing the tower seller
Scripting the tower seller
Finishing the tower seller
Upgrading the towers
How it works
Creating and placing the tower menu
Scripting the tower menu
Finalizing the tower menu
Summary
9. Finishing the Tower Defense Game
Getting ready
Waypoints for enemies
Getting the waypoint coordinates
Implementing waypoints in the Game Manager
Passing waypoints to the enemies
Integrating the UI into the game
Integrating the Lives Counter
Integrating the Money Counter
Placing the towers
Allowed areas
Scripting the placement script
Final tweaking of the Tower prefab
Creating an enemy spawner
Finishing the gameplay
Winning conditions
Losing conditions
Upgrading towers
Finishing the TowerScript
Final adjustments to the TowerMenuScript
Practice makes perfect
Summary
Goodbye

Unity 5.x 2D Game Development Blueprints

Unity 5.x 2D Game Development Blueprints

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.com

Credits

Authors

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

About the Authors

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.

About the Reviewers

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.

www.PacktPub.com

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.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Free access for Packt account holders

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.

Preface

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.

What this book covers

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.

What you need for this book

For this book, you will need Unity 5.x and Tiled Map Editor 0.16.1.

Who this book is 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 to build a range of awesome 2D games in different genres.

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:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.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 WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

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!

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/Unity5x2DGameDevelopmentBlueprints_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.

Chapter 1.  Sprites

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:

Using the 2D mode within UnityImporting and rendering spritesCreating sprite sheets and atlasesBeginning to use scripting

2D mode

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.

Note

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.

Custom packages

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