Mastering Unity 2D Game Development
eBook - ePub

Mastering Unity 2D Game Development

  1. 474 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mastering Unity 2D Game Development

Book details
Book preview
Table of contents
Citations

About This Book

Unity3D has long been seen as a massive 3D game-making middleware system, with lots of power and an easy-to-use editor. Now, with 2D games back in fashion, Unity has created a 2D toolset for developers with the know-how to create great games.

If you are looking for a book that will show you how to make a fully functional, customizable RPG game end to end, then this is the book for you. You will learn how to build an RPG game framework, learning lots of tips and tricks along the way, from advanced C# scripting to getting the most out of Unity's built in features such as Mecanim and curves in ways you may have not even considered.

By the end of this book, you will be able to architect, create, deploy, and integrate your game with all of your intended platforms, and have the knowledge to build and customize the Unity editor for the games you create with confidence. You will also be tooled with tricks from the trade on marketing, monetization, targeting as many platforms as possible, with a keen focus on how to best profit from your title.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Mastering Unity 2D Game Development by Simon Jackson in PDF and/or ePUB format, as well as other popular books in Computer Science & Digital Media. We have over one million books available in our catalogue for you to explore.

Information

Year
2014
ISBN
9781849697347
Edition
1

Mastering Unity 2D Game Development


Table of Contents

Mastering Unity 2D Game Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
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. Overview
Getting assets
Collection of sites
Welcome to 2D
The new 2D mode
Sprites
Sprite Renderer
Sprite Editor
Spritesheets
Texture atlases
Sprite meshes
The Box2D physics system
The new animation Dope Sheet
Other Unity 4.3 improvements
Improved Mecanim performance
The Windows Phone API improvements and Windows 8.1 support
Dynamic Nav Mesh (Pro version only)
Editor updates
MonoDevelop 4.01
Movie textures
Summary
2. Building a Character
Getting your project started – the right way
Structure
Object naming
Understanding components
Accessing components using a shortcut
A better way to use components – referencing
An even better way
Creating the project
Classes
The object-orientated design
The game structure
The common game object
The player object
More later
Planning behaviors
Behaviors for the common game object
Behaviors for the player's character
Introducing the Unity sprite system
Importing sprites
Texture type – sprite
Sprite Mode – single/multiple
Packing tag
Pixels to units
The Sprite Editor button
Sprite Editor
Sprite splitter (slicer)
Automatic
Grid (manual)
View controls
Sprite region manipulation
Putting it together
Importing our main character
The hero
Controlling the hero
Going further
Summary
3. Getting Animated
Sprite animation
Animation components
Animation controllers
Animation clips
The Animator component
Setting up animation controllers
Setting up animation clips
Manual animation clip creation
Automatic animation clip creation
Animator Dope Sheet
The time/recording controls
Selecting the animation clip
The sample rate (frames per second)
Animation properties
Timeline
Dope/curve view
Putting it together
Setting up the animation controller
Adding your first animation clip (idle)
Adding another animation clip (run)
Connecting animation states
Accessing controllers from a script
Extra credit
Getting curvy
Going further
Summary
4. The Game World
Backgrounds and layers
To slice or not to slice
The town background
The town buildings
The extra scenery
Building the scene
Adding the town background
Sprite sorting layers
Sprite sorting order
Updating the scene Sorting Layers
Working with the camera
Comparing Update, FixedUpdate, and LateUpdate
The perils of resolution
A better FollowCamera script
Transitioning and bounds
Towns with borders
Journeying onwards
Planning for the larger picture
Backgrounds and active elements
Parallaxing
Foreground objects
Shaders and 2D
Going further
Summary
5. NPCs and Interactions
Considering an RPG
Advanced programming techniques
Singletons and managers
The manager approach – using empty game objects
The singleton approach – using the C# singleton pattern
Communicating between game objects
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
Putting it all together
Getting the NPC's talking
The conversation object
Saving and serializing the object for later
The Conversation Component
Building a basic conversation system
The manager
Starting a conversation
Displaying the conversation
Adding more
Connecting the dots
Going further
Summary
6. The Big Wild World
The larger view
Types of maps
Fixed maps
Generated maps
In-game generated maps
2D doesn't mean you have to use only 2D
Going procedural
Screen space and world space
Putting it together
Adding the map
Adding places of interest
Creating the MapPoint prefabs for reuse
Updating the NavigationPrompt script
Updating the NavigationManager script
Traveling by click or touch
Managing input
Managing input priorities
Managing input order
Getting curvy
Fixing the start location
Traveling too far
Transitions
Updating level loading to use fading
Updating build settings to include new scenes
Going further
Summary
7. Encountering Enemies and Running Away
Event systems
Exploring randomness
Planning for random code/generation
True randomness
Basic Artificial Intelligence
State machines
Defining states
Simple singular choice
Planning for multiple cases
State managers
Sensors
Putting it together
Building the new scene
Adding the first enemy
Spawning the horde
Getting back home
The missing random piece
One last thing
Going further
Summary
8. Shopping for Weapons
Why do we shop?
The power of an item
Building your shop
Laying out your inventory
Rule of '99
Encumbrance system
Slot-based system
A mini game
Real world
Getting paid
Paid
Paid with trial
Ad supported
In-app purchase
In-game currency
Putting it together
Gathering the shop assets
Building the shop scene
Creating inventory items
Managing the shop
Adding 2D button behaviors
Updating the player inventory definition
Stocking the shop
Leaving the shop
Entering the shop
Managing your inventory
Ad...

Table of contents

  1. Mastering Unity 2D Game Development