Unity in Action, Second Edition
Joseph Hocking
  • MEAP began July 2017
  • Publication in Early 2018 (estimated)
  • ISBN 9781617294969
  • 325 pages (estimated)
  • printed in black & white


An eBook copy of the previous edition, Unity in Action (First Edition), is included at no additional cost. It will be automatically added to your Manning Bookshelf within 24 hours of purchase.

Manning's bestselling and highly recommended Unity book has been fully revised! Unity in Action, Second Edition teaches you to write and deploy games with the Unity game development platform. You'll master the Unity toolset from the ground up, adding the skills you need to go from application coder to game developer. Inside, you'll use the powerful C# language, Unity's intuitive workflow tools, and a state-of-the-art rendering engine to build and deploy mobile, desktop, and console games. In each chapter, you'll discover new projects that introduce specific Unity features and game development strategies. As you read and practice, you'll learn everything from first-person control schemes to adding audio and interactive objects, as you build up a well-rounded skill set for creating and deploying amazing games. Fully updated to include the latest changes to Unity, new best practices, and an entire chapter on building 2D platformers with Unity's expanded 2D toolkit, this book is essential for any aspiring game developer.

"Reading the book is like having the author sitting next to me, teaching me in a 1-1 style on how to build games and force me to find the time to get building."

~ Robin Dewson

"A fantastic way to get up to speed quickly and effectively."

~ Dan Kacenjar

"I am new to the subject and was able to follow the content and understand it 100%."

~ Tanya Wilke

"Easily one of the best ways to learn Unity."

~ Shiloh Morris

Table of Contents detailed table of contents

Part 1: First Steps

1. Getting to know Unity

1.1. Why is Unity so great?

1.1.1. Unity’s strengths and advantages

1.1.2. Downsides to be aware of

1.1.3. Example games built with Unity

1.2. How to use Unity

1.2.1. Scene view, Game view, and the Toolbar

1.2.2. Using the mouse and keyboard

1.2.3. The Hierarchy tab and the Inspector

1.2.4. The Project and Console tabs

1.3. Getting up and running with Unity programming

1.3.1. How code runs in Unity: script components

1.3.2. Using MonoDevelop, the cross-platform IDE

1.3.3. Printing to the console: Hello World!

1.4. Summary

2. Building a demo that puts you in 3D space

2.1. Before you start…​

2.1.1. Planning the project

2.1.2. Understanding 3D coordinate space

2.2. Begin the project: place objects in the scene

2.2.1. The scenery: floor, outer walls, inner walls

2.2.2. Lights and cameras

2.2.3. The player’s collider and viewpoint

2.3. Making things move: a script that applies transforms

2.3.1. Diagramming how movement is programmed

2.3.2. Writing code to implement the diagram

2.3.3. Local vs. global coordinate space

2.4. Script component for looking around: MouseLook

2.4.1. Horizontal rotation that tracks mouse movement

2.4.2. Vertical rotation with limits

2.4.3. Horizontal and vertical rotation at the same time

2.5. Keyboard input component: first-person controls

2.5.1. Responding to key presses

2.5.2. Setting a rate of movement independent of the computer’s speed

2.5.3. Moving the CharacterController for collision detection

2.5.4. Adjusting components for walking instead of flying

2.6. Summary

3. Adding enemies and projectiles to the 3D game

3.1. Shooting via raycasts

3.1.1. What is raycasting?

3.1.2. Using the command ScreenPointToRay for shooting

3.1.3. Adding visual indicators for aiming and hits

3.2. Scripting reactive targets

3.2.1. Determining what was hit

3.2.2. Alert the target that it was hit

3.3. Basic wandering AI

3.3.1. Diagramming how basic AI works

3.3.2. "Seeing" obstacles with a raycast

3.3.3. Tracking the character’s state

3.4. Spawning enemy prefabs

3.4.1. What is a prefab?

3.4.2. Creating the enemy prefab

3.4.3. Instantiating from an invisible SceneController

3.5. Shooting via instantiating objects

3.5.1. Creating the projectile prefab

3.5.2. Shooting the projectile and colliding with a target

3.5.3. Damaging the player

3.6. Summary

4. Developing graphics for your game

4.1. Understanding art assets

4.2. Building basic 3D scenery: whiteboxing

4.2.1. Whiteboxing explained

4.2.2. Drawing a floor plan for the level

4.2.3. Laying out primitives according to the plan

4.3. Texture the scene with 2D images

4.3.1. Choosing a file format

4.3.2. Importing an image file

4.3.3. Applying the image

4.4. Generating sky visuals using texture images

4.4.1. What is a skybox?

4.4.2. Creating a new skybox material

4.5. Working with custom 3D models

4.5.1. Which file format to choose?

4.5.2. Exporting and importing the model

4.6. Creating effects using particle systems

4.6.1. Adjusting parameters on the default effect

4.6.2. Applying a new texture for fire

4.6.3. Attaching particle effects to 3D objects

4.7. Summary

Part 2: Getting Comfortable

5. Building a Memory game using Unity’s 2D functionality

5.1. Setting everything up for 2D graphics

5.1.1. Preparing the project

5.1.2. Displaying 2D images (aka sprites)

5.1.3. Switching the camera to 2D mode

5.2. Building a card object and making it react to clicks

5.2.1. Building the object out of sprites

5.2.2. Mouse input code

5.2.3. Revealing the card on click

5.3. Displaying the various card images

5.3.1. Loading images programmatically

5.3.2. Setting the image from an invisible SceneController

5.3.3. Instantiating a grid of cards

5.3.4. Shuffling the cards

5.4. Making and scoring matches

5.4.1. Storing and comparing revealed cards

5.4.2. Hiding mismatched cards

5.4.3. Text display for the score

5.5. Restart button

5.5.1. Programming a UIButton component using SendMessage

5.5.2. Calling LoadScene from SceneController

5.6. Summary

6. Creating a basic 2D Platformer

6.1. Setting Up the Graphics

6.1.1. Placing Walls and Floor

6.1.2. Importing Sprite Sheets

6.2. Moving the Player Left and Right

6.2.1. Writing Keyboard Controls

6.2.2. Colliding with the Walls

6.3. Playing the Sprite’s Animation

6.3.1. Explaining the Mecanim Animation System

6.3.2. Triggering Animations from Code

6.4. Adding the Ability to Jump

6.4.1. Falling from Gravity

6.4.2. Applying an Upward Impulse

6.4.3. Detecting the Ground

6.5. Additional Features for a Platform Game

6.5.1. Unusual Floors: Slopes and One-Way Platforms

6.5.2. Implementing Moving Platforms

6.5.3. Camera Control

6.6. Summary

7. Putting a 2D GUI in a 3D Game

8. Creating a 3rd Person Game:Player Movement and Animation

9. Adding Interactive Devices andItems within the Game

Part 3: Strong Finish

10. Connecting Your Game to the Internet

11. Playing Audio: Sound Effects and Music

12. Putting the Parts Together into a Complete Game

13. Deploying Your Game to Players� Devices

14. Afterword: Where to go from Here


Appendix A: Scene Navigation and Keyboard Shortcuts

Appendix B: External Tools used alongside Unity

Appendix C: Modeling a Bench in Blender

Appendix D: Online Learning Resources

About the Technology

Great computer games combine sophisticated graphics, artful programming, specialized features, and even some advanced math and physics. Not for the faint of heart! Fortunately, the Unity game development platform handles a lot of the heavy lifting for you, so you can concentrate on delighting your users with entertaining gameplay. With its single codebase approach that minimizes inefficient switching among development tools and concentrates your attention on making great interactive experiences, Unity is perfect for game devs of all experience levels. You get an intuitive drag-and-drop GUI, along with support for deep scripting with JavaScript and C#. With a huge ecosystem of pre-built game assets, an enthusiastic community of fellow developers, and support for nearly every platform, Unity is a great choice to make your dream game a reality.

What's inside

  • Covers new best practices, Unity updates, and more
  • Work with 2D and 3D games
  • Characters that run, jump, and bump into things
  • Build code architectures that manage the game's state
  • Connect your games to the Internet
  • Deploy games to tons of platforms, such as web and mobile

About the reader

Written for those who know how to program, in C# or a similar OO language. No previous Unity experience or game development knowledge is assumed.

About the author

Joe Hocking is a software engineer specializing in interactive media development (especially video games). He currently works for Synapse Games and has taught classes at the University of Illinois at Chicago, the School of the Art Institute of Chicago, and Columbia College Chicago.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $44.99 pBook + eBook + liveBook
MEAP eBook $35.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks