Preface

Video games are a cultural phenomenon that have captivated, entertained, and moved billions of people worldwide over the past 60 years. As an industry and movement, video games are an exciting place to be, both for the developer and the artist. In these roles, your vision, ideas, and work can influence wide audiences, shaping and changing generation after generation in an unprecedented way. There has been a general movement toward democratizing game development recently, making the development process simpler, smoother, and more accessible to a wider audience, including developers working from home with minimal budgets. Instrumental in this movement is the Unity engine, which forms the main subject of this book. The Unity engine is a computer program that works with your existing asset pipeline (such as 3D modeling software) and is intended for compiling video games that work seamlessly across multiple platforms and devices, including Windows, Mac, Linux, Android, and iOS. Using Unity, developers import ready-made assets (such as music, textures, and 3D models) and assemble them into a coherent whole, forming a game world that works by a unified logic. The latest version is free for most people to download and use, and it works well with many other programs, including free software such as GIMP and Blender. This book focuses on the Unity engine and how it can be used in a practical context for making playable and fun games. No prior knowledge of Unity is expected, although some knowledge of programming and scripting, such as JavaScript, ActionScript, C, C++, Java, or ideally C#, would be beneficial.

Who this book is for

You don't need to have any previous experience with Unity to enjoy Unity 2020 by Example, although ideally, you will have basic knowledge of C#.

What this book covers

Chapter 1, Exploring the Fundamentals of Unity, begins our journey into Unity by creating a first-person collection game. This is a great starting point if you are totally new to Unity and are ready to create your first game.

Chapter 2, Creating a Collection Game, continues from the previous chapter and completes the first project. It assumes that you have completed the first chapter and brings closure to our project, leading neatly to the next chapter.

Chapter 3, Creating a Space Shooter, marks the beginning of our second project, focusing on the creation of a space shooter game. Here, we will create a project in which the player must shoot the oncoming enemies.

Chapter 4, Continuing the Space Shooter, completes the space shooter project by adding final touches to it, including projectile spawning and object pooling.

Chapter 5, Creating a 2D Adventure Game, enters the world of 2D and UI functionality. Here, we'll explore Unity's wide range of 2D features by making a side-view platformer game that relies on 2D physics.

Chapter 6, Continuing the 2D Adventure, continues the 2D adventure game project that was started in the previous chapter, linking together with the overarching game logic and adding additional levels using Sprite Shaping.

Chapter 7, Completing the 2D Adventure, completes the project started in Chapter 5, Creating a 2D Adventure Game, with the addition of a quest system and an NPC. This is a great place to see how multiple parts and facets of a game come together to form a whole.

Chapter 8, Creating Artificial Intelligence, focuses on artificial intelligence and creating enemies that can patrol, chase, and attack the player's character at relevant times, while cleverly navigating their way around the level.

Chapter 9, Continuing with Intelligent Enemies, brings closure to the AI project started in the previous chapter. Here, we'll see how to use finite-state machines to achieve powerful intelligence functionality that'll help us in a variety of scenarios.

Chapter 10, Evolving AI Using ML-Agents, approaches AI from a different angle. Whereas previous chapters have relied on hardcoding NPC behavior, in this chapter, we will evolve the required behavior using ML-Agents.

Chapter 11, Entering Virtual Reality, explores how to create a first-person shooter in VR where the player must tackle waves of oncoming enemies. In this chapter, we will lay the foundations for creating a VR game.

Chapter 12, Completing the VR Game, completes the VR project by adding gameplay elements and core functionality, and by creating a build.

Chapter 13, Creating an Augmented Reality Game Using AR Foundation, continues the exploration of Extended Reality, but this time by creating an Augmented Reality game. In this chapter, you'll also be introduced to the Universal Render Pipeline.

Chapter 14, Completing the AR game with the Universal Render Pipeline, completes the project started in the previous chapter. You'll learn how to detect surfaces in the real world and use that data to spawn AR objects.

To get the most out of this book

This book contains almost everything you need to follow along. Each chapter considers practical, real-world projects for learning Unity and includes companion files that can be downloaded and used. Apart from this book, the only thing you need is a copy of the latest version of Unity. At the time of writing, this is Unity 2020.1. This software is available for free as a personal edition, and it can be downloaded from the Unity website at https://unity3d.com/get-unity/download.

In addition to Unity, if you want to create props, character models, and other 3D assets, you'll also need 3D modeling and animation software, such as 3DS Max, Maya, or Blender; you'll also need image editing software, such as Photoshop or GIMP. Blender can be downloaded and used for free from http://www.blender.org/. Also, GIMP can be downloaded and used for free from https://www.gimp.org/.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

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 athttps://github.com/PacktPublishing/Unity-2020-By-Example-Third-Edition. 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/9781800203389_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: "Rename it Turtle."

A block of code is set as follows:

public class ObjectPool : MonoBehaviour

{

public void DeSpawn(Transform ObjectToDespawn)

{

ObjectToDespawn.gameObject.SetActive(false);

ObjectToDespawn.SetParent(transform);

ObjectToDespawn.position = Vector3.zero;

}

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: "Select the Android tab."

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 [email protected].

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 [email protected] 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset