Preface – Hands-On Unity 2020 Game Development

Preface

I still remember that moment of my life when I was afraid of telling my parents that I was going to study game development. At that time and where I was, that was considered a childish desire by most parents, and a career with no future, but I was stubborn enough to not care and to follow my dream. Today, game development is one of the biggest industries, generating more revenue than even the film industry.

Of course, following my dream was more difficult than I thought. Sooner or later, people chasing this particular dream have to face the fact that developing games is a difficult task that requires a deep level of knowledge in different areas. Sadly, most people give up due to this difficulty level, but I strongly believe that with proper guidance and tools, you can make your career path easier for you to follow. In my case, what helped me to flatten the learning curve was learning using Unity.

Welcome to this book about Unity 2020. Here you will learn how to use the most recent Unity features to create your first video game in the simplest way possible. Unity is a tool that provides you with powerful but easy-to-use features to solve the most common problems in game development, such as rendering, animation, physics, sound, effects, and so on. We will be using all those features to create a simple but complete game, learning all the nuances needed to handle Unity.

By the end of this book, you will be able to use Unity in a way that will allow you to start studying in depth that area of game development that you are interested in starting your career in, or that will simply allow you to create hobby games just for the joy of doing it. Unity is a versatile tool that can be used both in professional and amateur projects, and every day it is being used by more and more people.

It is worth mentioning that Unity can be used to create not only games but any kind of interactive app, from simple mobile apps to complex training or education applications (known as serious gaming), using the latest technologies, such as augmented and virtual reality. So, even if we are creating a game here, you are starting a learning path that can end in lots of possible specializations.

Who this book is for

People with different backgrounds can take advantage of either the whole book or just parts of it, thanks to the way it is structured. If you have basic object-oriented programming (OOP) knowledge but have never created a game before, or have never created one in Unity, you will find the book to be a nice introduction to game development and Unity's concepts, from the basic to the advanced. You will also find most of this book useful even if you are a seasoned Unity developer who wants to learn how to use its latest features.

On the other hand, if you don't have any programming knowledge, you can also gain from the book, as most chapters don't require programming experience to learn from them. Those chapters will give you a robust basic skillset using which you can start learning how to code in Unity, and by the time you have learned those basics of coding, you can get into the scripting-focused chapters of this book.

What this book covers

Chapter 1, Designing a Game from Scratch, is where we will discuss the details of the game we are going to create in the book before even opening Unity for the first time.

Chapter 2, Setting Up Unity, is where you will learn how to install and set up Unity on your computer, and is also where you will create your first project.

Chapter 3, Working with Scenes and GameObjects, is where we will learn about the concepts of Scenes and GameObjects, which are part of Unity's way of describing what your game world is composed of.

Chapter 4, Grayboxing with Terrain and ProBuilder, is where we will be creating our first level layout and prototyping it with the Terrain and ProBuilder Unity features.

Chapter 5, Importing and Integrating Assets, introduces graphics. As Unity is not a tool for creating graphics, but for displaying them, we will learn how to improve our Scene art by importing graphics into Unity.

Chapter 6, Materials and Effects with URP and Shader Graph, is where we will see how to use one of the latest Unity Render Systems (Universal Render Pipeline) and how to create effects with the Shader Graph feature.

Chapter 7, Visual Effects with Particle Systems and VFX Graph, is where you will learn how to create visual effects, for things such as water and fire, using the two main Unity tools for doing so: Particle Systems and the VFX Graph.

Chapter 8, Lighting Using the Universal Render Pipeline, covers lighting. Lighting is a concept big enough to have its own chapter. Here we will deepen our knowledge of the Universal Render Pipeline, specifically looking at its lighting capabilities.

Chapter 9, Fullscreen Effects with Post-Processing, delves into effects and post-processing. To get that cinematic effect that most modern games have today, we will learn how to add a layer of effects on top of our Scene graphics using the post-processing feature of the Universal Render Pipeline.

Chapter 10, Sound and Music Integration, gets into an often-neglected area: sound. Being underestimated by most beginner developers, here we will learn how to properly add sound and music to our game, taking into consideration its impact on performance.

Chapter 11, User Interface Design, explores the use of the user interface (UI). Of all the graphic-based ways to communicate information to the user, the use of the UI is the most direct. We will learn how to display information in the form of text, images, and life bars using the Unity UI system.

Chapter 12, Creating Animations with Animator, Cinemachine, and Timeline, moves us on from our simple static Scene. In this chapter, we will start moving our characters with animations and creating cutscenes with the latest Unity features for doing so.

Chapter 13, Introduction to Unity Scripting with C#, is the first programming chapter of the book. We will learn how to create our first script using C# in the Unity way.

Chapter 14, Implementing Movement and Spawning, is where we will learn how to program the movement of our objects and how to spawn them. General programming knowledge is assumed from now on.

Chapter 15, Physics Collisions and Health System, is where you will learn how to configure the physics settings of objects to detect when two of them collide and react to the collision. To put this in practice, we'll be creating a health system.

Chapter 16, Win and Lose Conditions, is where we will be detecting when the game should end, which will be when the player either wins it or loses it.

Chapter 17, Scripting the UI, Sounds, and Graphics, is where we will be making the previously created UI to show the relevant and current information of the game, such as the player's health and the score. Also, we'll look at sounds being played when necessary and the use of visual effects to reflect the actions of the player.

Chapter 18, Implementing Game AI to Build Enemies, is where we will be creating basic AI using several Unity features to create challenging enemies in our game.

Chapter 19, Scene Performance Optimization, explores performance. Making our game perform well is no easy task, and it is certainly a requirement if we want to release it. Here we will be learning how to profile our game's performance and tackle the most common performance issues.

Chapter 20, Building the Project, is where we will learn how to convert our Unity project into an executable format to distribute it to other people and run it without Unity being installed.

Chapter 21, Finishing Touches, is where we will briefly discuss how to move forward with the development of our game after finishing this book, discussing topics such as how to iterate and release the game.

Chapter 22, Augmented Reality in Unity, gives you an introduction to augmented reality (AR). In this extra chapter, we will be learning how to create an AR application with Unity's AR Foundation package, one of the most recently released ways to create AR applications with Unity.

To get the most out of this book

You will be developing a full project throughout the chapters of this book, and while you can just read the chapters, I highly recommend that you practice all the steps in this project as you advance through the book, to get the experience needed to properly learn the concepts we look at here. The chapters are designed so that you can customize the game according to your preferences, but do consider not deviating too much from the main idea.

The project files are split into folders per chapter and are designed in a cumulative way, each folder having just the new files introduced by the chapter or the ones that are different from previous chapters. This means, for example, that if one file doesn't change since Chapter 1, you won't find it in the folders for Chapter 2 onwards. You can open the scene file in each chapter folder to see how the game should look like at the end of that chapter. This allows you to see just what gets changed in each chapter and means that you can easily identify necessary changes. If, for some reason, you can't finish Chapter 3, for example, you can just pick things up again with Chapter 4 solved folder.

We advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing the latter will help you avoid any potential errors related to the copying and pasting of code.

Take into account that this book and its examples has been written using Unity 2020.1.0f1, the latest version available at the moment. This is the first Unity 2020 release, and while there might be newer versions, consider that if you use them, there might be slight differences in screenshots or steps depicted in the book, but nothing hard to sort out.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Unity-2020-Game-Development. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here:

https://static.packt-cdn.com/downloads/9781838642006_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Set its shader to Universal Render Pipeline/Particles/Unlit."

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Create a new empty GameObject (using GameObject | Create Empty)."

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.