InformIT.com

Sams Teach Yourself Unity Game Development in 24 Hours (Learning Lab)

 

Author: Ben Tristem and Mike Geig
Publisher: Sams Publishing
ISBN: 978-0-13-427066-1
Copyright © 2016 by Pearson Education

Contents at a Glance

Preface

HOUR 1: Introduction to Unity

HOUR 2: Game Objects

HOUR 3: Models, Materials, and Textures

HOUR 4: Terrain

HOUR 5: Environments

HOUR 6: Lights and Cameras

HOUR 7: Game 1: Amazing Racer

HOUR 8: Scripting—Part 1

HOUR 9: Scripting—Part 2

HOUR 10: Collision

HOUR 11: Game 2: Chaos Ball

HOUR 12: Prefabs

HOUR 13: 2D Games Tools

HOUR 14: User Interfaces

HOUR 15: Game 3: Captain Blaster

HOUR 16: Particle Systems

HOUR 17: Animations

HOUR 18: Animators

HOUR 19: Game 4: Gauntlet Runner

HOUR 20: Audio

HOUR 21: Mobile Development

HOUR 22: Game Revisions

HOUR 23: Polish and Deploy

HOUR 24: Wrap Up


Preface

The Unity game engine is an incredibly powerful and popular choice for professional and amateur game developers alike. This book has been written to get readers up to speed and working in Unity as fast as possible (about 24 hours to be exact) while covering fundamental principles of game development. Unlike other books that only cover specific topics or spend the entire time teaching a single game, this book covers a large array of topics while still managing to contain four games! Talk about a bargain. By the time you are done reading this book, you won’t have just theoretical knowledge of the Unity game engine. You will have a portfolio of games to go with it.

Who Should Read This Book

This book is for anyone looking to learn how to use the Unity game engine. Whether you are a student or a development expert, there is something to learn in these pages. It is not assumed that you have any prior game development knowledge or experience, so don’t worry if this is your first foray into the art of making games. Take your time and have fun. You will be learning in no time.

How This Book Is Organized and What It Covers

Following the Sam’s Teach Yourself approach, this book is organized into 24 chapters that should take approximately 1 hour each to work through. The chapters include the following:

  • Hour 1, “Introduction to Unity”—This hour gets you up and running with the various components of the Unity game engine.
  • Hour 2, “Game Objects”—Hour 2 teaches you how to use the fundamental building blocks of the Unity game engine—the game object. You also learn about coordinate systems and transformations.
  • Hour 3, “Models, Materials, and Textures”—In this hour, you learn to work with Unity’s graphical asset pipeline as you apply shaders and textures to materials. You also learn how to apply those materials to a variety of 3D objects.
  • Hour 4, “Terrain”—In Hour 4, you learn to sculpt game worlds using Unity’s terrain system. Don’t be afraid to get your hands dirty as you dig around and create unique and stunning landscapes.
  • Hour 5, “Environments”—In this hour, you learn to apply environmental effects to your sculpted terrain. Time to plant some trees!
  • Hour 6, “Lights and Cameras’—Hour 6 covers lights and cameras in great detail.
  • Hour 7, “Game 1—Amazing Racer”: Time for your first game. In Hour 7, you create Amazing Racer, which requires you to take all the knowledge you have gained so far and apply it.
  • Hour 8, ‘Scripting Part 1”—In Hour 8, you begin your foray into scripting with Unity. If you’ve never programmed before, don’t worry. We go slowly as you learn the basics.
  • Hour 9, “Scripting Part 2”—In this hour, you expand on what you learned in Hour 8. This time, you focus on more advanced topics.
  • Hour 10, “Collision”—Hour 10 walks you through the various collision interactions that are common in modern video games. You learn about physical as well as trigger collisions. You also learn to create physical materials to add some variety to your objects.
  • Hour 11, “Game 2—Chaos Ball”—Time for another game! In this hour, you create Chaos Ball. This title certainly lives up to its name as you implement various collisions, physical materials, and goals. Prepare to mix strategy with twitch reaction.
  • Hour 12, “Prefabs”—Prefabs are a great way to create repeatable game objects. In Hour 12, you learn to create and modify prefabs. You also learn to build them in scripts.
  • Hour 13, “2D Game Tools”—In Hour 13, you learn about Unity’s powerful tools for creating 2D games, including how to work with sprites and Box2D physics.
  • Hour 14, “User Interfaces”—In this hour, you learn how to use Unity’s powerful User Interface system, and how to create a menu for your game.
  • Hour 15, “Game 3—Captain Blaster”—Game number 3! In this hour, you make Captain Blaster, a retro-style spaceship shooting game.
  • Hour 16, “Particle Systems”—Time to learn about particle effects. In this chapter, you experiment with Unity’s particle system to create cool effects, and apply them to your projects.
  • Hour 17, “Animations”—In Hour 17, you get to learn about animations and Unity’s animation system. You experiment 2D and 3D animation, and some powerful animation tools.
  • Hour 18, “Animators”—Hour 18 is all about Unity’s Mecanim animation system. You learn how to use the powerful state machine, and how to blend animations.
  • Hour 19, “Game 4—Gauntlet Runner”—Lucky game number 4 is called Gauntlet Runner. This game explores a new way to scroll backgrounds and how to implement animator controllers to build complex blended animations.
  • Hour 20, “Audio”—Hour 20 has you adding important ambient effects via audio. You learn about 2D and 3D audio and their different properties.
  • Hour 21, “Mobile Development”—In this hour, you learn how to build games for mobile devices. You also learn to utilize a mobile device’s built-in accelerometer and multitouch display.
  • Hour 22, “Game Revisions”—It’s time to go back and revisit the four games you have made. This time you modify them to work on a mobile device. You get to see which control schemes translate well to mobile and which don’t.
  • Hour 23, “Polish and Deploy”—Time to learn how to add multiple scenes and persist data between scenes. You also learn about the deployment settings and playing your games.
  • Hour 24, “Wrap Up”—Here, you look back and summarize the journey you went on to learn Unity. This hour provides useful information about what you have done and where to go next.

Thank you for reading my preface! We hope you enjoy this book and learn much from it. Good luck on your journey with the Unity game engine!

Companion Files

To access the companion files:

1. Log into your Informit.com account.

2. Go to the Registered Products tab and click on the 'Access Bonus Content' link that appears next to your Learning Lab.


Praise for Sams Teach Yourself Unity Game Development in 24 Hours, Second Edition

“Rapid prototyping is one of the most valuable skills in the industry, and this book will help you get up and running with enough time left over to finish a weekend game jam. Despite being a long time Unity user, I learned a dozen new time-saving tricks in the first half of this book alone!”

—Andy Moore, Captain, Radial Games

“24 hours, 3 games, and a plethora of lessons on not only how to build games in Unity but how to be a game designer, programmer, and developer. Sams Teach Yourself Unity Game Development in 24 Hours, 2/e is a great foundation for budding game builders.”

—Tim J. Harrington, EdD, Higher Education Games and Social Learning Specialist

Sams Teach Yourself Unity Game Development in 24 Hours, 2/e provides a terrific and thorough introductory look at the Unity development environment, game terminology, and game-making process, with plenty of hands-on examples, exercises and quizzes that will have readers creating their own games in no time!”

—Dr. Kimberley Voll, Game Developer/Researcher, ZanyT Games

“This is the book we have been waiting for! Ben and Mike don’t just explain how to use Unity, they explain how to use it properly so you won’t get stuck later. Every Unity developer should carry this around in their back pocket.”

—Efraim Meulenberg, Co-Founder, TornadoTwins

“Unity’s fun to play with and fun to learn. It’s become extremely popular as a platform for game studios ranging in size from one to one hundred people. Game engines are only as good as the games they enable; as a developer you need to ship games. That’s where this book will help you. I especially enjoyed the starter 2D and 3D games developed in this book. They gather the material learned in previous chapters and show you how the parts fit together into a working whole. Reading this book will inspire you to create your own experiences and share them with the world.”

—Jeff Somers, Developer on Rock Band, Guitar Hero, Phase and Dance Central

“This book will make all of your dreams come true, provided your dreams exclusively revolve around game development in Unity. Plus, I’m British, so it must be true.”

—Will Goldstone, Unity Technologies

Sams Teach Yourself Unity Game Development in 24 Hours, 2/e is a comprehensive primer for learning Unity3D akin to eating dessert first-you get to the fun quickly!”

—Elliott Mitchell, Co-founder, Vermont Digital Arts/Boston Unity Group

About the Authors

Ben Tristem is an internet entrepreneur, focusing on teaching technical subjects to beginners. Ben has been passionate about using computers since the days of the ZX81, and is now a world-class technology trainer. At the time of writing, Ben has over 60,000 students and more than 1,200 5-star reviews on his online courses. In previous lives, Ben has been an RAF pilot, financial trader, stunt man, helicopter pilot, franchise creator, and more. Now that he has two kids, Toby and Lucy, he has settled down to focus on what he loves—teaching.

Mike Geig is both an experienced teacher and game developer, with a foot firmly in both camps. Mike is a Trainer for Unity Technologies where he develops and delivers recorded, live, and onsite learning content. He enjoys loitering and accordions. His Pearson video series, Game Development Essentials with Unity 4 LiveLessons, is a key title on Unity and rumor has it that people really enjoyed the first edition of Sams Teach Yourself Unity Game Development in 24 Hours. Mike was once set on fire and has over a million “likes” on Facebook.

Dedication

From Ben:

To Lizzie: For being an amazing wife, enabling me to thrive.

From Mike:

To Dad: Everything worth learning, I learned from you.

Acknowledgments

From Ben:

I’ve had so much support in writing this book, thank you.

Firstly to Mike for writing the first edition of the book. Having this to work from was an amazing starting point for this second edition. You have been fantastic to work with, and I’m grateful for your time.

Thanks to Laura, our editor, for making it easy for me to write my first book. Thank you also for keeping us all on track so that it got written on time.

Thanks to my beautiful wife, Lizzie, and to my kids, Lucy and Toby, for your patience as I worked late to get the book finished. I’m very grateful for your understanding.

Last but not least to my Mum, without her I probably wouldn’t be writing this!

From Mike:

A big “thank you” goes out to everyone who helped me write this book.

First and foremost, thank you Kara for keeping me on track. I don’t know what we’ll be talking about when this book comes out, but whatever it is, you are probably right. Love ya babe.

Link and Luke: We should take it easy on mommy for a little while. I think she’s about to crack.

Thanks to my parents. As I am now a parent myself, I recognize how hard it was for you not to strangle or stab me. Thanks for not strangling or stabbing me.

Thanks to Angelina Jolie. Due to your role in the spectacular movie Hackers (1995), I decided to learn how to use a computer. You underestimate the impact you had on 10-year-olds at the time. You’re elite!

To the inventor of beef jerky: History may have forgotten your name, but definitely not your product. I love that stuff. Thanks!

Thank you to our technical editors: Tim and Jeff. Your corrections and insights played a vital role in making this a better product.

Thank you Laura for convincing me to write this book. Also thank you for buying me lunch at GDC. I feel that lunch, the best of all three meals, specifically enabled me to finish this.

Finally, a “thank you” is in order for Unity Technologies. If you never made the Unity game engine, this book would be very weird and confusing.

We Want to Hear from You

As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what we’re doing right, what we could do better, what areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass our way.

You can email or write directly to let us know what you did or didn’t like about this book—as well as what we can do to make our books stronger.

Please note that we cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail we receive, we might not be able to reply to every message.

When you write, please be sure to include this book’s title and author, as well as your name and contact information.

Email:    feedbach@samspublishing.com

Mail:      Sams Publishing
               ATTN: Reader Feedback
               800 East 96th Street
               Indianapolis, IN 46240 USA

Reader Services

Visit our website and register this book at www.informit.com/register for convenient access to any updates, downloads, or errata that might be available for this book.