Book Image

Unity 3D Game Development

By : Anthony Davis, Travis Baptiste, Russell Craig, Ryan Stunkel
Book Image

Unity 3D Game Development

By: Anthony Davis, Travis Baptiste, Russell Craig, Ryan Stunkel

Overview of this book

This book, written by a team of experts at Unity Technologies, follows an informal, demystifying approach to the world of game development. Within Unity 3D Game Development, you will learn to: Design and build 3D characters and game environments Think about the users’ interactions with your game Develop an interface and apply visual effects to add an emotional connection to your world Gain a solid foundation of sound design, animations, and lighting Build, test, and add final touches The book contains expert insights that you’ll read before you look into the project on GitHub to understand all the underpinnings. This way, you get to see the end result, and you’re allowed to be creative and give your own thoughts to design, as well as work through the process with the new tools we introduce. Join the book community on Discord to read this book with Unity game developers, and the team of authors. Ask questions, build teams, chat with the authors, participate in events and much more. The link to join is included in the book.
Table of Contents (16 chapters)
14
Other Books You May Enjoy
15
Index

Your first Unity project

You’ve put together a concept that you want to develop, and now we need to get Unity and create a project. To do this, we need to get the Unity Hub and then choose a version, followed by a template to start with.

Unity Hub

Unity Hub is a small application that holds all of the projects in a centralized location so all of your projects are easily accessible as well as the versions of Unity you have installed. To acquire Unity Hub, you need to go to unity.com and create a UnityID. After you create an account, click the blue button named Get Started. Follow the prompts that best make sense for your needs and operating system. Download and install Unity Hub and let’s get creating!

Choosing a version

Unity runs multiple versions at once. There are Alpha, Beta, Official, and LTS releases.

Alpha versions have experimental features that may not be fully complete or production-ready and are not recommended for builds as there may be features causing build-breaking bugs. Studios and enthusiasts may use this for testing mechanics, engine features, or packages. They are generally one release ahead of official releases. Beta is similar to Alpha versions; however, they are experimental versions of the most current official release. Official releases are stable current releases. LTS means Long-Term Support. These are the final releases of a version with minor hotfixes if bugs are found.

An easy way to see the versions is through the Unity Hub. An example of what this may look like can be seen in Figure 2.4:

Figure 2.4: Example list of Unity versions

LTS releases are recommended for a production application. If your team is experimenting or looking to prototype with new features, it would only be possible in prerelease versions. After choosing a version for your project to be built in, you need to choose a template from Unity’s options as you make a new project.

This book, however, is version independent. If you’ve bought this book after 2022, the book is still as relevant as it can be. The screenshots may have slight UI changes, but the foundations still remain intact.

Choosing a template

Unity presents you with a few template choices when you press the New button on the projects tab. This gives you the options of 2D, 3D, Universal Rendering Pipeline (URP), and High-Definition Rendering Pipeline (HDRP). There are large rendering differences as well as some functionality that might be interesting to you and your team to work with. These differences between these templates, arose when the Scriptable Rendering Pipeline (SRP) came to life!

Scriptable rendering pipeline

Rendering and computer graphics are a detailed subject that you could get a PhD in, so we will scratch the surface of what is possible through a rendering pipeline. The top level of the pipeline entails three tasks: Culling, Rendering, and Post-Processing. In each of these categories, many tasks are taking place in certain orders and to certain degrees of accuracy. The primary function of all of this is to optimize the view to the end user for a high frame rate as well as maintain the art style that is required for the experience you are wanting for the user.

With the advent of the SRP, these templates split into three main categories: Built-in, Universal, and High Definition. To get an idea of these three templates, let’s break them out into their respective groups and dive in a little bit further. For our project, we will be using Universal Rendering as we will be utilizing several features inside this rendering pipeline.

Built-In Rendering

This is an older pipeline that doesn’t use scriptable pipelines. There are a great many applications for the built-in renderer. Both of the 2D and 3D templates run Built-In Rendering systems. This is also the standard for which most of the assets in the asset store were built before the SRP came out. You can think of “Built-in” as the base experience in Unity. There are several reasons why you may not want to use the Built-In Renderer. If you are looking to use volumetric lighting, GPU particles, or ray tracing you would want to look into the scriptable render pipelines below.

Universal Rendering

The Universal Rendering pipeline is aptly named as it has the most features available with a scriptable rendering pipeline available. If you are looking to make a 2D game, this is the best option to choose as it has built-in, pixel-perfect rendering, 2D lights, and 2D shadows. For the 3D option, this is also a fantastic choice. There are two graphs available to both URP and HDRP, which are ShaderGraph and VFXGraph. ShaderGraph is a visual shader creation tool that allows for complex shaders to be written visually. VFXGraph’s primary function is to be a particle system focused on GPU particles, allowing you to create millions of particles on screen at the same time for stunning visuals.

We would like to use GPU-based particles, in our project which VFXGraph is responsible for handling, as well as show the use of ShaderGraph. With these requirements, we chose to work within URP as our rendering pipeline.

If you are looking for more of a physically accurate rendering system with ray tracing and volumetric clouds, then HDRP is what you are looking for.

High-Definition Rendering

This rendering pipeline has one major purpose: to give the best-looking output while remaining as optimized as possible. Whether to use HDRP or not is a widely discussed topic. There are several main reasons why HDRP would be the option for you. This is if you are looking for a physical-based sky with cloud layers, volumetric clouds, multiple directional lights, highly customizable shadow options, and ray tracing to include raytraced reflections, volumetrics, and multiple high-level shader outputs. There are many other high-level rendering options that HDRP only can provide. These concepts are deep topics in the computer graphics world and we implore you to look them up to see the beautiful work of what real-time rendering is becoming.