Mastering Unity 2D Game Development - Second Edition
By Simon Jackson and Ashley Godbold
()
About this ebook
Related to Mastering Unity 2D Game Development - Second Edition
Related ebooks
Mastering Unity 2D Game Development Rating: 5 out of 5 stars5/5Unity Game Development Scripting Rating: 0 out of 5 stars0 ratingsBuilding Levels in Unity Rating: 0 out of 5 stars0 ratingsUnity Game Development Essentials Rating: 5 out of 5 stars5/5GameMaker Cookbook Rating: 0 out of 5 stars0 ratingsGetting Started with Unity 5 Rating: 5 out of 5 stars5/5Procedural Content Generation for C++ Game Development Rating: 3 out of 5 stars3/5SFML Game Development Rating: 0 out of 5 stars0 ratingsUnity Game Development Blueprints Rating: 0 out of 5 stars0 ratingsBlueprints Visual Scripting for Unreal Engine Rating: 0 out of 5 stars0 ratingsUnreal Engine Game Development Cookbook Rating: 0 out of 5 stars0 ratingsLearning C# by Developing Games with Unity 5.x - Second Edition Rating: 5 out of 5 stars5/5SFML Game Development By Example Rating: 0 out of 5 stars0 ratingsUnity from Zero to Proficiency (Foundations) Fifth Edition: Unity from Zero to Proficiency, #1 Rating: 5 out of 5 stars5/5Unity 5.x Cookbook Rating: 0 out of 5 stars0 ratingsUnity 5 Game Optimization Rating: 0 out of 5 stars0 ratingsLearning C++ by Creating Games with UE4 Rating: 3 out of 5 stars3/5Mastering Unity Scripting Rating: 0 out of 5 stars0 ratingsMobile Game Design Essentials Rating: 0 out of 5 stars0 ratingsUnity from Zero to Proficiency (Proficient): Unity from Zero to Proficiency, #5 Rating: 5 out of 5 stars5/5Unity from Zero to Proficiency (Intermediate): Unity from Zero to Proficiency, #3 Rating: 2 out of 5 stars2/5Unity Multiplayer Games Rating: 5 out of 5 stars5/5Mastering SFML Game Development Rating: 0 out of 5 stars0 ratingsExtending Unity with Editor Scripting Rating: 0 out of 5 stars0 ratingsUnreal Engine 4 Game Development Essentials Rating: 4 out of 5 stars4/5Blueprints Visual Scripting for Unreal Engine - Second Edition: The faster way to build games using UE4 Blueprints, 2nd Edition Rating: 0 out of 5 stars0 ratingsUnity in Action, Third Edition: Multiplatform game development in C# Rating: 0 out of 5 stars0 ratingsGodot from Zero to Proficiency (Beginner): Godot from Zero to Proficiency, #2 Rating: 5 out of 5 stars5/5Getting Started with Unity 5.x 2D Game Development Rating: 0 out of 5 stars0 ratingsGodot from Zero to Proficiency (Intermediate): Godot from Zero to Proficiency, #3 Rating: 5 out of 5 stars5/5
Applications & Software For You
Logic Pro X For Dummies Rating: 0 out of 5 stars0 ratingsLearn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Six Figure Blogging In 3 Months Rating: 4 out of 5 stars4/5GarageBand Basics: The Complete Guide to GarageBand: Music Rating: 0 out of 5 stars0 ratingsGarageBand For Dummies Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5The Unofficial Guide to Open Broadcaster Software: OBS: The World's Most Popular Free Live-Streaming Application Rating: 0 out of 5 stars0 ratingsAdobe Photoshop: A Complete Course and Compendium of Features Rating: 5 out of 5 stars5/5Adobe Illustrator: A Complete Course and Compendium of Features Rating: 0 out of 5 stars0 ratingsThe Essential Persona Lifecycle: Your Guide to Building and Using Personas Rating: 4 out of 5 stars4/5Blender 3D Basics Beginner's Guide Second Edition Rating: 5 out of 5 stars5/5How to Create Cpn Numbers the Right way: A Step by Step Guide to Creating cpn Numbers Legally Rating: 4 out of 5 stars4/5Sound Design for Filmmakers: Film School Sound Rating: 5 out of 5 stars5/5Mastering ChatGPT Rating: 0 out of 5 stars0 ratingsVocal Rescue: Rediscover the Beauty, Power and Freedom in Your Singing Rating: 4 out of 5 stars4/5Adobe Premiere Pro: A Complete Course and Compendium of Features Rating: 0 out of 5 stars0 ratingsSynthesizer Cookbook: How to Use Filters: Sound Design for Beginners, #2 Rating: 3 out of 5 stars3/5Experts' Guide to OneNote Rating: 5 out of 5 stars5/5The Chromebook Infused Classroom: Using Blended Learning to Create Engaging, Student-Centered Classrooms Rating: 0 out of 5 stars0 ratingsiPhone Photography For Dummies Rating: 0 out of 5 stars0 ratingsFL Studio Cookbook Rating: 4 out of 5 stars4/5Essential Affinity Photo 2 Rating: 0 out of 5 stars0 ratingsHow Do I Do That In InDesign? Rating: 5 out of 5 stars5/5Mastering QuickBooks 2020: The ultimate guide to bookkeeping and QuickBooks Online Rating: 0 out of 5 stars0 ratingsThe Best Hacking Tricks for Beginners Rating: 4 out of 5 stars4/5
Reviews for Mastering Unity 2D Game Development - Second Edition
0 ratings0 reviews
Book preview
Mastering Unity 2D Game Development - Second Edition - Simon Jackson
Table of Contents
Mastering Unity 2D Game Development - Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
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. Overview
Getting assets
Unity's 2D features
2D mode versus 3D mode
Working with sprites
Sprite Renderer
Sprite Editor
Sprite sheets
Texture atlases
Physics 2D
Changes to Unity 5
Licensing
Component access
Animator changes
Audio mixing
Summary
2. Building Your Project and Character
Project overview and structure
Project overview
Structure
Asset naming
Creating the project
Creating a scene
Sprite system
Importing sprites
Texture Type - Sprite (2D and UI)
Sprite Mode - Single/Multiple/Polygon
Packing Tag
Pixels Per Units
Pivot
Generate Mip Maps
Filter Mode
Default settings and per-platform overrides
Sprite Editor
Sprite slicer
Automatic
Grid By Cell Size and Grid By Cell Count (Manual)
View controls
Sprite region manipulation
Importing our main character
GameObjects and components
Sprite GameObjects
Bringing our hero into the scene
Classes
MonoDevelop
The object-orientated design
The game structure
The common game object
The player object
Planning behaviors
Behaviors for the common game object
Coding with components
Accessing components
Referencing a component
Controlling the hero
Going further
Summary
3. Getting Animated
Fundamentals of sprite animation
Animation clips
Animation Dope Sheet
The time/recording controls (1)
Animation drop-down selection (2)
The sample rate (frames per second) (3)
Animation properties (4)
Timeline (5)
Curve view (6)
The Animation Controllers
The Animator component
Animating the main character
Adding your first Animation Clip
Setting up the Animator and default state
Adding the other Animation Clips
Planning the animation transitions
Connecting the animation states
Accessing controllers from a script
Making her stop animating and face the correct direction
Going further
Summary
4. The Town View
Backgrounds and layers
To slice or not to slice
The town background
The town buildings and roads
The extra scenery
Building the scene
Adding the town background
Sprite sorting layers
Sprite Sorting Order
Updating the scene sorting layers
Building out the scene
Working with the camera
Comparing Update, FixedUpdate, and LateUpdate
Moving our camera with the player
The perils of resolution
Setting our aspect ratio and camera parameters
Transitioning and bounds
Towns with borders
Journeying onward
Going further
Summary
5. Working with Unitys UI System
UI Canvas
EventSystem
Canvas Render Mode
Screen Space - Overlay
Screen Space - Camera
World Space
Using multiple Canvases
UI Text and Images
UI Text
UI Image
UI Layout and Rect Transform
Rect Tool
Pivot
Anchors
UI Buttons
Transition types
Text child
On Click ()
Going further
Summary
6. NPCs and Interactions
Considering an RPG
Advanced programming techniques
Singletons and managers
The manager approach - using empty GameObjects
The singleton approach - using the C# singleton pattern
Communicating between GameObjects
Delegates
The configurable method pattern
The delegation pattern
Compound delegates
Events
Messaging
A better way
Background tasks and coroutines
Enter coroutines
IEnumerator
Yielding
Starting coroutines
Closing the gap
Serialization and scripting
Saving and managing asset data
Using the serialized files in the editor
Accessing the .asset files in the code
Adding NPCs and a conversation system to our game
Let the player walk around the NPC
Stopping the player from walking through the NPC
Getting the NPCs talking
The conversation object
Saving and serializing the object for later
The conversation component
Building a basic conversation system
The manager
Starting a conversation
Preparing the UI
Displaying the conversation
Connecting the dots
Going further
Summary
7. The World Map
The larger view
Types of map
Fixed maps
Generated maps
In-game generated maps
Going procedural
Creating our game's map
Adding the world map
Adding a player prefab to the overworld
Adding places of interest
Leaving town
Creating a NavigationManager script
Blocking off paths
Updating build settings to include new scenes
Changing scenes
Returning to town
Updating the NavigationManager script
Going further
Summary
8. Encountering Enemies and Running Away
Event systems
Exploring randomness
True randomness
Planning for random code/generation
Basic Artificial Intelligence
State machines
Defining states
Simple singular choice
Planning for multiple cases
State managers
Sensors
Setting up your battle scene
Building the new scene
Adding the first enemy
Spawning the Dragons
Creating the BattleManager
Allowing the player to run away
Starting the battle
Saving the map position
Stop immediately re-entering battle
Going back to town
Going further
Summary
9. Getting Ready to Fight
Setting up our battle state manager
The battle state manager
Getting to the state manager in the code
Starting the battle
Introductory animation
Efficient RPG UI overlays
The adventurer's overlay
A context-sensitive overlay
Modern floating UI approach
Balancing the need
Bring on the GUI
Laying out the HUD
Displaying the correct buttons
Going further
Summary
10. The Battle Begins
Designing an interesting battle system
Leveling up
Balancing
Preparing to attack a single enemy
Beefing up the enemy AI
The enemy profile/controller
Updating the Dragon prefab
Setting up the enemy profile in the code
Selecting an attack
Adding a visual effect to attack selection
Selecting a target
The selection circle prefab
Adding selection logic to the EnemyController class
Attack! Attack!
Using particle effects to represent an attack
Creating the materials for the particle effects
Adding the particles
Displaying the particles upon attack
Finishing up the battle
Going further
Summary
11. Shopping for Items
Why do we shop?
The power of an item
Building your shop
Laying out your inventory
Rule of 99'
Encumbrance systems
Slot-based systems
A mini game
Real world
Creating a shop and inventory
Gathering shop assets
Building the shop scene
Creating inventory items
Managing the shop
Updating the player inventory definition
Stocking the shop
Linking up the buttons
Turning off the Buy Button
Entering the shop
Leaving the shop
Managing your inventory
Adding objects to the player's inventory
Going further
Summary
12. Sound and Music
Choosing the appropriate sound and music
Where to get sound and music for your game
Free resources
Audio listeners and audio sources
Adding background music
Creating a splash screen
Adding the audio source
Transitioning to the next scene
Keeping the music after the scene transition
Adding sound effects
Adding a sound to the buy button
Muting/unmuting audio
Going further
Summary
13. Putting a Bow on It
Building in-game menu structures
The screens
Splash screens
Loading screens
The main menu
Save slots/level selections
Settings pages
The About screen
Privacy policy
Pause screens
Additional menus (purchasing, achievements, leaderboards, and so on)
Social
The flow
Finishing our splash screen
Building our start screen
Extending the editor
The property drawers
Examples property drawers
Built-in property drawers
Custom property drawers
Custom editors
The editor window
Gizmos
Building your editor menus
Adding a MenuItem attribute
Enabling/disabling a MenuItem attribute
Adding shortcut keys to a MenuItem attribute
Adding contextual MenuItems
Running scripts in the Editor folder
Alternative approaches
The [InitialiseOnLoad] attribute
Editor application callbacks
Mixing it up
Working with settings
Using PlayerPrefs
Serializing your data
Saving data to disk
Backing up to the Web
Going further
Summary
14. Deployment and Beyond
Handling platform differences
Preprocessor directives
Pushing code from Unity
Processing assets
Processing the build
Building your assets
Packaging gotchas
Distributing to mobile
Social network integration
Monetization
Paid
Paid with trial
Ad supported
In-app purchases
In-game currency
Going further
Summary
Mastering Unity 2D Game Development - Second Edition
Mastering Unity 2D Game Development - Second Edition
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: August 2014
Second edition: October 2016
Production reference: 1071016
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-345-6
www.packtpub.com
Credits
About the Authors
Dr. Ashley Godbold is a programmer, game designer, artist, mathematician, and teacher. She holds a Bachelor of Science in Mathematics, a Master of Science in Mathematics, a Bachelor of Science in Game Art and Design, and a Doctor of Computer Science in Emerging Media, where her dissertation research focused on educational video game design. She works full-time as a game developer and also runs a small indie/passion studio. She teaches college courses in Unity, 3ds Max, Adobe Flash, game design, and mathematics.
I would like to thank my husband, Kyle, and my daughter, Claire, for supporting me after I made the crazy decision to write a book and a dissertation at the same time. I would also like to thank my good friend, Danny Rich, for being the person with whom I initially set out to learn Unity and for helping me with character art in this book.
I'd also like to thank everyone at Packt Publishing for helping me through this process, particularly Smeet Thakkar, Prashanth G Rao, and Sushant Nadkar for all of their help through this process.
Simon Jackson has been a tinkerer, engineer, problem solver, and solution gatherer ever since his early years. In short, he loves to break things apart, figure out how they work, and then put them back together; usually better than before.
He started way back when with his first computer, the Commodore Vic20. It was simple, used a tape deck, and forced you to write programs in Basic or assembly language; those were fun times. From there, he progressed through the ZX Spectrum +2 and the joyous days of modern graphics, but still with the 30-minute load times from a trusty tape deck. Games were his passion even then, which led to many requests for another gaming machine, but Santa brought him an Amstrad 1640, his first PC. From there, his tinkering and building exploded, and that machine ended up being a huge monstrosity with so many add-ons and tweaked fixes. He was Frankenstein, and this PC became his own personal monster crafted from so many parts. Good times.
This passion led him down many paths, and he learned to help educate others on the tips and tricks he learned along the way; these skills have equipped him well for the future.
Today, he would class himself as a game development generalist. He works with many different frameworks, each time digging down and ripping them apart, and then showing whoever would listen through his blog, videos, and speaking events how to build awesome frameworks and titles. This has been throughout many generations of C++, MDX, XNA (what a breath of fresh air that was), MonoGame, Unity3D, The Sunburn Gaming Engine, HTML, and a bunch of other proprietary frameworks—he did them all. This gives him a very balanced view of how to build and manage many different types of multiplatform titles.
He didn't stop there as he regularly contributed to the MonoGame project, adding new features and samples, and publishing on NuGet. He also has several of his own open source projects and actively seeks any new and interesting ones to help with.
By day, he is a lowly lead technical architect working in the healthcare industry, seeking to improve patients' health and care through better software (a challenge to be sure). By night, he truly soars! Building, tinkering, and educating while trying to push game titles of his own. One day they will pay the bills, but until then, he still leads a double life.
I would like to thank my family above all, my wife, Caroline and my four amazing children (Alexander, Caitlin, Jessica, and Nathan), for putting up with me and giving me the space to write this title as well as my other extravagances—they truly lift me up and keep me sane. They are my rock, my shore, my world.
I would also like to thank Jamie Hales of PixelBalloon who generously donated some content for the Appendix and gave me new ideas and insights to look into.
A big shout out to all the guys who ran and helped me out with the Unity porting events, which I supported throughout the course of this book, namely Lee Stott, Simon Michael, Riaz Amhed, Louis Sykes, Ben Beagley, Josh Naylor, Mahmud Chowdhury, and Michael Cameron. Also, the Unity evangelists who were badgered throughout the events and were pumped for hidden details: Joe Robins and Andy Touch. Truly a great crowd to get game developers energized and their titles onto as many platforms as possible. Lots of weekends lost to writing, but the book was better, for they led to so many different experiences.
Finally, thanks to the reviewers of this title who kept me grounded and on target, although that didn't help to keep the page count low—thanks for your support guys.
About the Reviewer
Claudio Scolastici is a game designer with a background in Psychology, Cognitive Science and AI. He is currently a game designer for the video game and VR/AR developer SpinVector, author of cool games such as From Cheese and Artusi Cooking Time.
He is also a guest tutor at Digital Tutors/Pluralsight and a book author for Packt.
www.PacktPub.com
eBooks, discount offers, and more
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 customercare@packtpub.com 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://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Preface
The Unity engine has revolutionized the gaming industry, by making it easier than ever for indie game developers to create quality games on a budget. Hobbyists and students can use this powerful engine to build 2D and 3D games, to play, distribute, and even sell for free! Unity 4.3 dramatically reformed the way developers could create 2D games when they included sprite rendering, 2D physics, and sprite key-frame animation. Unity 4.6 further shook the gaming world by adding a new and elegant UI system that perfectly complimented the 2D games developers began creating. Now, Unity 5 has arrived! And this text will explore all the wonderful features it has to offer for 2D game development.
In this book, you will learn how to build an RPG game framework, learning lots of tips and tricks along the way. You will start by making a character and a village for the character to interact with NPCs. Then you will develop an overworld map for the character to explore that will be loaded with enemies who randomly attack her. After that, you'll cover the process involved in setting up a turn based battle system along with all of the necessary steps for creating a functional GUI. Following that, you'll develop a shop and inventory system and then implement sound and music. By the end of this book, you will be able to architect, create, deploy, your game as well as have the knowledge to build and customize the Unity editor.
What this book covers
Chapter 1, Overview. This chapter gives a basic overview of the 2D features provided within Unity 5. It also provides general guidance for finding free assets to use within 2D projects. Lastly, it points out key differences between Unity 5 and Unity 4.
Chapter 2, Building your Project and Character. This chapter covers the steps necessary to start building a project. It describes object oriented programming, how it is used in Unity, and the basic structure of a class in C# using MonoDevelop. This chapter also describes the process of importing, editing, and implementing, 2D sprites into the Unity engine, as well as the programming required to move the sprite around the screen with the player's interaction.
Chapter 3, Getting Animated. This chapter introduces animation in Unity by utilizing the various animation components. It describes the process of converting a sprite sheet to an animation clip and implementing the Animator component. It also describes the process of setting up the Animator Controller and explains how to implement animation parameters using scripting.
Chapter 4, The Town View. This chapter explains the process of setting up the town in which the character will walk around. It also explains the process of working with the camera and how to program the functionality necessary for the character to interact with her environment.
Chapter 5, Working with Unity's UI System. This chapter gives a general overview of the UI system implemented in Unity 4.6.
Chapter 6, NPCS and Interactions. This chapter covers the overall structure of interacting with non-player characters within an RPG. It then describes the process of writing and implementing the code necessary to allow the player to speak with the NPCs, and displaying the conversation utilizing the UI system.
Chapter 7, The World Map. This chapter discusses the process of building a map for the player to navigate and allowing the player character to exit the initial town.
Chapter 8, Encountering Enemies and Running Away. This chapter discusses the process of creating a battle scene that contains randomly spawning enemies. It then covers the programming required to have the player character transition in to random battles and transition back to the map by selecting the option to run away.
Chapter 9, Getting Ready to Fight. This chapter discusses the process of developing a battle introduction animation and the GUI that will allow the player to interact with the battle.
Chapter 10, The Battle Begins. This chapter further develops the battle system, by implementing the code that allows the player to select various attacks, incorporating particle systems to represent attacks, and utilizing an event system.
Chapter 11, Shopping for Items. This chapter discusses the process of creating a shop in which the player can buy items and an inventory system in which the player can save the purchased items.
Chapter 12, Sound and Music. This chapter covers the basics of sound integration utilizing audio listeners and sources, by adding background music and a sound effect when the player purchases an item.
Chapter 13, Putting a Bow on It. This chapter covers the finishing touches necessary to create a complete game. This includes packaging the game, implementing a splash screen and menu system, extending the editor, and adding a system to save the player’s data.
Chapter 14, Deployment and Beyond. This final chapter discusses how to convert the final game to a playable game.
What you need for this book
In order to follow this book, you will need the Unity game engine available at https://unity3d.com/get-unity/download.
You will need to download version 5.3 or higher. This text was written using 5.3.4. If for some reason, you want to get Unity 5.3.4 instead of the most recent version, you can get archived versions from https://unity3d.com/get-unity/download/archive.
To get the art assets and code discussed within the book, you should download the book's support files.
Who this book is for
This book is intended for anyone looking to get started in developing 2D games with Unity 5 or anyone already familiar with Unity 2D wishing to expand or supplement their current Unity knowledge. A basic understanding of programming logic is needed to begin learning with this book, but intermediate and advanced programming topic are explained thoroughly so that coders of any level can follow along. Previous programming experience in C# is not required.
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: This is done by calling DontDestroyOnLoad when you initialize the class.
A block of code is set as follows:
//Set the public property of the singleton
MySingletonManager.Instance.MyTestProperty = World Hello
;
//Run the public method from the singleton
MySingletonManager.Instance.DoSomethingAwesome();
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: After selecting Create project, you'll be brought to the Editor Window
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 feedback@packtpub.com, 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.
You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.
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/Mastering-Unity-2D-Game-Development-Second-Edition. 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/MasteringUnity2DGameDevelopmentSecondEdition_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 copyright@packtpub.com 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 questions@packtpub.com, and we will do our best to address the problem.
Chapter 1. Overview
Arguably, the most important parts of any project are knowing where to start and what tools you have in your arsenal before setting out to make your game. In this chapter, we will give a brief overview of the 2D tools offered in Unity 5 and explore the new features available to Unity 5.
Since this is the first chapter, let's cover how this book is structured. The main aim of this book is to build a fully functional, retro-style, Role-Playing Game (RPG) framework and cover all the main aspects of any good and well-rounded RPG game, including the following features:
Character development and setup
Building your main game view
A wider world view
Events and encounters
Shopping and inventory systems
Battles
We will be visiting places such as the following:
Your home town, as shown in the following screenshot:
The local shop, as shown in the following screenshot:
The outside world, as shown in the following screenshot:
Battling dragons in the dark forest, as shown in the following screenshot:
In this chapter, we will walk through the key terms used when working in 2D, as well as the big changes made in Unity 5 relevant to 2D game creation. We will kick off the next chapter by building the foundations of our project with some of the best practices in the industry, including guidance from the Unity team themselves (either direct from team members or from responses in the forums).
The following topics will be covered in this chapter:
Overview of Unity's 2D system
Rundown of new features provided in Unity