Table Of ContentHands-On Unity 2021
Game Development
Second Edition
Create, customize, and optimize your own
professional games from scratch with Unity 2021
Nicolas Alejandro Borromeo
BIRMINGHAM—MUMBAI
Hands-On Unity 2021 Game Development
Second Edition
Copyright © 2021 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, nor Packt Publishing or its dealers
and distributors, will be held liable for any damages caused or alleged to have been 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.
Associate Group Product Manager: Rohit Rajkumar
Associate Publishing Product Manager: Ashitosh Gupta
Senior Editor: Hayden Edwards
Content Development Editor: Aamir Ahmed
Technical Editor: Saurabh Kadave
Copy Editor: Safis Editing
Project Coordinator: Ajesh Devavaram
Proofreader: Safis Editing
Indexer: Pratik Shirodkar
Production Designer: Shankar Kalbhor
First published: July 2020
Second edition: August 2021
Production reference: 1190821
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80107-148-2
www.packt.com
To Dad, who spoiled me with computers to keep learning. I miss you.
Also, to my wife, for reminding me of what I am capable of.
– Nicolas Alejandro Borromeo
Contributors
About the author
Nicolas Alejandro Borromeo works as a senior Unity developer at Product Madness,
London. He was a game development career coordinator at Universidad Argentina
de la Empresa (UADE) and has taught game development at many other Argentine
universities, such as UTN, UAI, and USAL, and institutions such as Image Campus and
DaVinci, since 2012. Nicolas has been a Unity Certified Instructor since 2019, teaching
high-profile Unity clients all around the globe. He was an MMO client-side developer at
Band of Coders in Argentina and has been a Unity freelance developer since 2012.
About the reviewers
Levent Alpsal is a senior software and game developer. In 2008, he started working on
web-based projects, developing for the backend using PHP and SQL.
He started his focus on Unity and C# in 2015, working on many exciting simulation
projects using Unity, VR, motion platforms, and other technologies at Sanlab Simulation.
He has also developed many indie games and attended global game jams.
In 2020, he started his own company in the UK, Reenim Software LTD, providing software
and Unity development services globally.
Levent likes to develop creative DIY solutions to daily real-life problems using 3D
printing, thermoplastics, and K'Nex. He is the proud designer of a remote-controlled
model tank. Currently, he lives in London with his lovely wife and wonderful son.
Sungkuk Park is a Berlin-based game developer. He majored in art studies at Hongik
University in Seoul, Korea, but later became a software engineer in the gaming industry.
He is interested in almost everything about gaming. He is now on his way to becoming
a technical artist!
Here is a list of his publications:
• Authored Seamless Society, 21 July 2020, in collaboration with an online exhibition
platform DDDD
• Authored Wallpeckers: Breaking down the barriers between media, an article for the
Korean art magazine Misulsegye, in March 2019
• Authored The Possibility of the Impossibility of the "Art Games", an article for the
Korean art magazine Misulsegye, in February 2017
• Translated and edited Game Level Generation Using Neural Networks, a featured
post of Gamasutra
Table of Contents
Preface
Section 1 – Our First Level
1
Designing a Game from Scratch
Game concept 4 HUD 12
Game idea 5
The difficulty balance 13
Input controls 5
Difficulty balance questions 14
Winning and losing 7
Implementation plan 15
Game characters 8
Documentation 16
Hero 8
Game Design Document (GDD) 16
Enemies 8
GDD formats 17
Gameplay 9 GDD creation tools 17
Game-world layout 9 Elevator pitch 19
Starting condition 10 High concept 20
Ending condition 11 Tips for creating GDDs 21
Point system 12
Summary 24
2
Setting Up Unity
Why use a game engine such as Installing Unity 28
Unity? 26
Unity Technical Requirements 29
Past and present industry insight 26 Unity installs 29
Game engines 27 Installing Unity with Unity Hub 30
Benefits of using Unity 27
viii Table of Contents
Creating projects 36 Project structure 38
Creating a project 36
Summary 40
3
Working with Scenes and Game Objects
Manipulating scenes 42 Possible uses 60
The purpose of a scene 42
Prefabs 61
The Scene View 43
Creating Prefabs 62
Creating our first GameObject 44
Prefab-instance relationship 63
Navigating the Scene View 46
Prefab variants 66
Manipulating GameObjects 47
Saving scenes and projects 67
GameObjects and components 51
Saving our changes 68
Understanding components 52
Project structure 69
Manipulating components 53
Summary 71
Object hierarchies 58
Parenting objects 59
4
Grayboxing with Terrain and ProBuilder
Creating a Landscape with Installing ProBuilder 85
Terrain 74 Creating a Shape 87
Discussing Height Maps 74 Manipulating the mesh 88
Creating and configuring Height Maps 76 Adding details 94
Authoring Height Maps 79
Summary 97
Adding Height Map details 82
Creating Shapes with ProBuilder 85
5
Importing and Integrating Assets
Importing assets 99 Integrating assets 109
Importing assets from the internet 100 Integrating terrain textures 109
Importing assets from the Asset Store 102 Integrating meshes 112
Table of Contents ix
Integrating textures 114 Configuring textures 119
Assembling the scene 120
Configuring assets 116
Configuring meshes 117 Summary 124
Section 2 – Improving Graphics and Sound
6
Materials and Effects with URP and Shader Graph
Introducing shaders 128 Creating our first Shader Graph 139
Shader pipeline 128 Using textures 144
The Render Pipeline and URP 132 Combining Textures 153
URP's Built-in Shaders 134 Applying transparency 157
Creating Vertex Effects 160
Creating Shaders with Shader
Graph 138 Summary 162
7
Visual Effects with Particle Systems and Visual Effect Graph
Introduction to particle Creating complex simulations
systems 164 with Visual Effect Graph 177
Creating a basic particle system 165 Installing Visual Effect Graph 178
Using advanced modules 170 Creating and analyzing a Visual Effect
Graph 180
Creating fluid simulations 172
Creating a rain effect 184
Creating a waterfall effect 172
Summary 189
Creating a bonfire effect 174
8
Lighting Using the Universal Render Pipeline
Applying lighting 192 Applying shadows 207
Discussing lighting methods 192 Understanding shadow calculations 207
Configuring ambient lighting with Configuring performant shadows 213
skyboxes 198
Optimizing lighting 216
Configuring lighting in URP 203