Mastering Unity 2017 Game Development with C# Second Edition Create professional games with solid gameplay features and professional-grade workflow Alan Thorn BIRMINGHAM - MUMBAI Mastering Unity 2017 Game Development with C# Second Edition Copyright © 2017 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 author(s), 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: January 2017 Second edition: October 2017 Production reference: 1271017 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78847-983-7 www.packtpub.com Credits Author Copy Editor Alan Thorn Shaila Kusanale Reviewers Project Coordinator Michael Miles Devanshi Doshi Alessandro Mochi Commissioning Editor Proofreader Amarabha Banerjee Safis Editing Acquisition Editor Indexer Larissa Pinto Pratik Shirodkar Content Development Editor Graphics Onkar Wani Jason Monteiro Technical Editor Production Coordinator Harshal Kadam Arvindkumar Gupta About the Author Alan Thorn is a multidisciplinary game developer, author, and educator with 17 years of industry experience. He makes games for PC desktop, mobile, and VR. He founded Wax Lyrical Games and created the award-winning game Baron Wittard: Nemesis of Ragnarok, working as designer, programmer, and artist. He has written 23 technical books on game development and presented 19 video training courses. These cover gameplay programming, Unity development, and 3D modeling and animation. He has worked in game education as a senior lecturer for Teesside University, a lead teacher for Uppingham School, and a visiting lecturer for London South Bank University. Currently, he's the Head of Department for Games Design and Development at the National Film and Television School. This book would not have been possible if it hadn't been for the valuable help of many people. I would like to thank all my friends and family, and also the team at Packt Publishing. This includes Onkar Wani and Larissa Pinto. About the Reviewers Michael Miles is a manufacturing engineer working in the aerospace industry by day, and a Unity Game designer and C#, JavaScript, and Python developer the rest of the time. While he purchased his first computer in the early '80s, it was years later when he first got into programming, writing modifications for Doom during breaks at work. With gaming in general frowned upon, while working Michael put these skills to work, programming simulations for the various processes he used on the job. A few years later, he discovered Unity3D and Blender; using these applications, Michael creates interactive training and production-ready instruction tools for the assembly of parts for the aircraft his company builds. When not in front of a computer screen, he likes to play card games, board games with family and friends, and immerse himself in books from fantasy to theoretical physics. Thanks to my parents for always being there, supporting every decision I made, however unwise you thought it was at the time. Alessandro Mochi has been playing video games since the Amstrad and NES era, tackling all possible fields: PC, console, and mobile. They are his love, and designing them is his passion, used as a medium to transmit and evoke emotions. He gives a lot of importance to details while doing any work, and is well versed in project and team management, communication, and problem-solving skills. He is experienced in mechanical design, but is also quite good at programming (Unity, C#) and 3D modeling. With over 15 years of experience in IT and project management, he's currently pouring all of his heart and mind into the company he founded--Dapper Penguin Studios. Here, he tries to resurrect a lost genre in PC gaming--the industrial tycoon--with the flagship title Rise of Industry. Many studios have tried in recent years, and their failures serve as inspiration and fuel for his work, trying to give back to the gaming industry a fun, polished, and immortal experience. 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.comand 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://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 Customer Feedback Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1788479831. If you'd like to join our team of regular reviewers, you can email us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products! Table of Contents Preface 1 Chapter 1: Preparation and Asset Configuring 6 Getting clear on design 8 Target platforms 9 Intended audience 10 Genre 11 Game mode 12 Game objective 12 Asset preparation 13 Meshes - Work only with good topology 13 Meshes - Minimize polygon count 15 Meshes - Simulating bump details without geometry 18 Meshes - Minimize UV seams 22 Meshes - Export as FBX 24 Meshes - Use meters scale (metric) 25 Textures - Never use lossy compression 26 Textures - Power of 2 sizes 27 Textures - Alpha textures 29 Asset importing for Dead Keys 30 Importing textures 31 Importing meshes 38 Importing animations 52 Importing audio 57 Configuring materials 59 Summary 61 Chapter 2: Level Design and Structure 62 Setting the scene with a skybox 64 Level building - Modular construction sets 71 Level building - Organization and structure 78 Level design - Tips and tricks 81 Objective and feedback 82 Narrative 82 Believability and convenience 83 Atmosphere and aesthetic 83