Hands-On Unity 2020 Game Development
eBook - ePub

Hands-On Unity 2020 Game Development

Build, customize, and optimize professional games using Unity 2020 and C#

Nicolas Alejandro Borromeo

Share book
  1. 580 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Unity 2020 Game Development

Build, customize, and optimize professional games using Unity 2020 and C#

Nicolas Alejandro Borromeo

Book details
Book preview
Table of contents
Citations

About This Book

Build immersive game experiences using the new Unity 2020 features with this practical guide

Key Features

  • Unleash the capabilities of C# scripting for creating immersive UI, graphics, Game AI agents and much more
  • Explore Unity's latest tools, including Universal Render Pipeline, Shader Graph, and VFX graph, to enhance graphics and animation
  • Get started with building augmented reality experience using Unity's AR Foundation

Book Description

Over the years, the Unity game engine has extended its scope from just being about creating video games to building AR/VR experiences, complex simulations, real-time realistic rendering, films, and serious games for training and education. Its features for implementing gameplay, graphics, and customization using C# programming make Unity a comprehensive platform for developing professional-level, rich experiences.

With this book, you'll be able to build impressive Unity projects in a step-by-step manner and apply your knowledge of Unity concepts to create a real-world game. Complete with hands-on tutorials and projects, this easy-to-follow guide will show you how to develop your first complete game using a variety of Unity tools. As you make progress, you'll learn how to make the most of the Unity Editor and create scripts using the C# programming language. This Unity game development book will then take you through integrating graphics, sound, and animations and manipulating physics to create impressive mechanics for your games. You'll also learn how to code a simple AI agent to challenge the user and use profiling tools to ensure that the code runs in a performant way. Finally, you'll get to grips with Unity's AR Foundation for creating AR experiences for 3D apps and games.

By the end of this book, you'll have developed a complete game and will have built a solid foundation using Unity's tooling ecosystem to develop game projects of any scale.

What you will learn

  • Write scripts for customizing various aspects of a game, such as physics, gameplay, and UI
  • Program rich shaders and effects using Unity's new Shader Graph and Universal Render Pipeline
  • Implement postprocessing to increase graphics quality with full-screen effects
  • Create rich particle systems for your Unity games from scratch using VFX Graph and Shuriken
  • Add animations to your game using the Animator, Cinemachine, and Timeline
  • Implement game artificial intelligence (AI) to control character behavior
  • Detect and fix optimization issues using profilers and batching

Who this book is for

This book is for game developers looking to migrate to the Unity game engine. If you are a developer with some exposure to Unity, this book will help you explore its latest features. Prior experience with C# programming is required to get the most out of the book.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Hands-On Unity 2020 Game Development an online PDF/ePUB?
Yes, you can access Hands-On Unity 2020 Game Development by Nicolas Alejandro Borromeo in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in C#. We have over one million books available in our catalogue for you to explore.

Information

Year
2020
ISBN
9781838647605
Edition
1

Chapter 1: Designing a Game from Scratch

Welcome to the first chapter of the book! I am sure you are as super excited as I am to start this amazing journey into game development with Unity. We will be approaching game development in four parts. First, we will be talking about the basics of game development, looking at topics such as how to design your game before you start coding, and then we will prototype a simple first level using Unity. Then, we will dive into graphics to find out the look and feel of a good game. Later, we will learn how to get everything moving through the use of scripting; and, finally, we will see how you can finish and publish your game. As you go through the chapters, you will apply every concept to a full game project, so you will end the book with a fully functional shooter game.
In this chapter, we will design our game, Super Shooter. This phase is known as pre-production, where we will create a development plan. Our game design will include all the functionality we want in our game: the player character, the non-player characters, game assets, animations, and more. We will use screen mock-ups, as well as a narrative, to document our game's design. We will look at related concepts regarding the use of Unity for our game along the way. We will be discussing which pieces of documentation are necessary for all the design work we will be doing throughout this chapter.
Specifically, we will examine the following concepts in this chapter:
  • Game concept
  • Game characters
  • Gameplay
  • The difficulty balance
  • Documentation

Game concept

Why not just start developing our game instead of designing it? This question is spawned from the excitement of developing games, especially with the Unity game engine. All games start with an idea. That idea is translated into a design, and that design is the basis for development and, eventually, the final game.
A game's design is like a blueprint for a house. You would not consider building a house without a blueprint, and it is an equally bad idea to develop a game without designing it first. The reason for this is to save time and frustration. For larger projects, time wasted also means unnecessary funds are expended.
Imagine that you employed a project team of 12 developers, animators, and artists. If you shared your game idea, would they have enough to go on? Would they do great things, but not have a cohesive set of components for your game? All we are doing with our game design is documenting as much as we can in the beginning so that the development process is purposeful. Without question, you will continually modify your game's design during development, so having a strong base from which to start is critical to your success.
Our game design will serve as the foundation for the look of our game, what the player's objectives are, what the gameplay will be, and supporting user actions, animations, audio, artificial intelligence (AI), and victory conditions. That is a lot to think about and underscores the importance of translating the game idea into the game design.
Throughout the book, we will be covering a range of components. However, in this section, we will cover those that appear in the following list:
  • Game idea
  • Input controls
  • Winning and losing
So, let's look at each component in more detail.
Game idea
The basic concept of our Super Shooter game is that it will be a 3D game featuring a Futuristic Hero Soldier as the player character. The character must fight against Enemy Soldiers. These Enemies are intent on destroying our Hero's base and anyone that gets in their way, including our Hero. He will have a limited number of bullets he must keep track of.
Now that we have a general idea of what the game is going to be, let's talk about how the player will control the character.

Input controls

It is important to consider how players will interact with our game. The player will control our Hero using the standard set of controls. Players have an expectation that the industry norms for user controls will be implemented in games. So, our default set of user input controls, as shown in the following screenshot, will consist of the keyboard and mouse:
Figure 1.1 – Controls scheme
Figure 1.1 – Controls scheme
We will configure and program our game so that user input from the keyboard matches the key and action pairings shown in the following table:
Figure 1.2 – Keys mapping
Figure 1.2 – Keys mapping
The mouse will also be a significant source of user input. We will implement two components using the mouse, as indicated in the following table:
Figure 1.3 – Mouse mapping
Figure 1.3 – Mouse mapping
The left mouse button will be our action button. We will need to ensure bullets are shot only when the player has one or more bullets remaining.
That's how we handle input, but sometimes we need to end the game session! Let's talk about how the player will win and lose.

Winning and losing

Our winning condition will be when all the Enemy waves have been eliminated. There will be two different ways the player can lose the game. The first losing condition is when the base life becomes 0. The second losing condition is if the Hero's life becomes 0.
By this short description, you can tell that there will be several things to keep track of, including the following:
  • Number of remaining Waves
  • Number of our Base Life
  • Number of our Hero Life
Now, we have defined what is called the game "core loop" (star a level, play it, win/lose it, and repeat). Let's dive deeper into the specific details, starting with our characters.

Game characters

Our game will feature several objects, but only two game characters. The first game character is our Hero and will be controlled by the player. The second type of game character is the Enemies. They are non-player characters that are controlled by AI. Let's look more closely at both of these characters.

Hero

The player will play our game as the Hero, our game's protagonist. This is a character that we will import for use in our game. So, what can our Hero player character do? We already know we will be able to move them throughout our game environment using a combination of keyboard and mouse inputs. We also know that the left mouse button—our action button—will cause him to shoot bullets.
Important Note:
Because the Hero is controlled by a human player, it is referred to as the Player Character.
We will implement the following animations for the Hero:
  • Idle: This animation will play when the character is not being moved by the player.
  • Run: This animation will play when the character is being moved by the player.
  • Shoot: This is an animation that will cause the Hero to shoot a bullet.
That's our player. Now, let's discuss our enemy character.

Enemies

Our game's antagonist will be the Enemy Soldiers. We will control how many of them we want in our game and where they are placed. We will also control their behavior through AI. The Enemies will go straight to the base and, once there, they will start damaging it. We will determine how long it takes for our base to be completely destroyed.
Information Box:
Because the Enemy is controlled by AI and not a human player, it is referred to as a Non-Player Character.
We will implement the following animations for the Enemy soldiers:
  • Run: The Enemies will be able to run toward the Hero when they see him and will stop when they are near enough to the player to start attacking him.
  • Attacking: This animation will play when the Enemy is near enough to attack the base or the player.
  • Death: This animation will play when the Enemy is defeated by the player.
We will require careful planning and scripting to create the desired Enemy behaviors. The number and placement of the Enemies are decisions we will need to make.
That defines our characters' details. Now, let's discuss how the game will be played, looking at the specific details.

Gameplay

The game will start with the player in the center of the game world. The Hero, controlled by the player, will need to defend the Base from the Enemies. To fend off the Enemies, the Hero will have a starting number of bullets. The goal is to defeat all the Enemies before the Base is completely destroyed by them.
Let's look at how we will make all this happen. The following gameplay components are covered in this section:
  • Game-world layout
  • Starting condition
  • Ending condition
  • Point system
  • Heads-up display (HUD)
We will cover each of the preceding components and discuss how they change the game experience. Let's start by talking about how the game world will be designed.

Game-world layout

We will create our base environment, which consists of large metallic floor tiles, walls, doors where the enemies will be spawning, and our base building at the bottom part of the screen, where the enemies need to reach to start attacking it.
Here is a mock-up of the shape our game world will take:
Figure 1.4 – Base layout
Figure 1.4 – Base layout
There are four basic things illustrated in the preceding mock-up, listed as follows:
  • Wall: Impenetrable barriers that prevent the player from going outside the play area.
  • Door: Impenetrable as the walls but will also serve as the Spawn Position of the Enemies. The Enemies will spawn behind them and can penetrate them to enter our Base Area.
  • Player Start: Start Hero position.
  • Base Building: Our Base. The enemies must be close enough to attack it.
With our base level design finished, let's discuss how the player will enter that world in a gentle way.

Starting condition

When our game is first launched, we will have several starting conditions set. Here is a list of those conditions:
  • Number and placement of Enemies' Spawn Points (doors)
  • ...

Table of contents