Book Image

Getting Started with Unity 2018 - Third Edition

By : Dr. Edward Lavieri
Book Image

Getting Started with Unity 2018 - Third Edition

By: Dr. Edward Lavieri

Overview of this book

The Unity game engine has revolutionized the gaming industry with its complete set of intuitive tools and rapid workflows, which can be used to create interactive 3D content. With Unity, you can scaffold your way from the basics and make make stunning interactive games. This book will guide you through the entire process of creating a 3D game, from downloading the Unity game engine to publishing your game. It not only gives you a strong foundation, but puts you on the path to game development. Beginning with an overview of the Unity engine and its interface, you will walk through the process of creating a game environment and learn how to use built-in assets, as well as assets created with third-party 3D modeling tools such as Blender. Moving on, you will create custom scripts to control non-player character behaviors and gameplay. You will master exciting concepts such as Heads-Up-Displays, mini-maps, game navigation, sound effects, and lighting effects. Next, you’ll learn how to create your first VR experience, right from setting up the project to image effects. You'll be familiarized with all the tools that Unity has to offer to create your own immersive VR experiences. Each section is a stepping stone toward the completion of the final game. By the end of the book, you'll have learned advanced topics such as cross-platform considerations which enable your games to run on multiple platforms.
Table of Contents (21 chapters)
Title Page
Packt Upsell


With the pervasiveness of games and the use of gamification in nearly every industry, the desire to discover how to use state-of-the-art development software has never been so great. There is an increasing number of software tools available to help developers create amazing games for consoles, the web, desktop computers, and mobile devices. Game engines are among the most powerful of these tools available. The Unity 3D game engine is one of the elite game engines. It has been used to create popular 2D and 3D games by large game studios and indie developers. With a free version available, and the newest release of Unity, the time has never been better to start using Unity.

Getting Started with Unity 2018, Third Edition covers one of the most popular game engines available. This book will guide you through the entire process of creating a 3D game, from downloading the Unity game engine to publishing your game. You will enjoy the coverage of some exciting topics in this book, including player-controlled characters and animation. Whether you are just getting started as a game developer or have experience with Unity or other game engines, this book will provide you with a guided tour of developing games with Unity 2018. With clear explanations, tips, and ample screenshots, you will be provided with detailed steps to develop your game.

This book takes a practice hands-on approach to learning Unity 2018. As you progress through each chapter, you will build a 3D interactive game called Cucumber Beetle. As you create the game, you'll learn the key features of Unity 2018, including creating a game environment, animating characters, scripting, and more. All meshes, models, textures, animations, and other assets are available on the book's website.

By the time you complete the lessons in this book, you'll have the confidence to start using Unity 2018 to create your own games.

Who this book is for

This book is written for people new to Unity or those who have some experience with a version prior to Unity 2018. If you want to take a look at Unity 2018, get a refresher, or if you just want to see how games can be developed with a top game engine, this book is for you.

What this book covers

Chapter 1, Downloading and Installing Unity, gives an overview of game engines, followed by a deep look at Unity's beginnings, where the game engine is today, and how it progressed to being one of the top game engines in use today. Unity's capabilities and features are highlighted, and instructions are provided for downloading and installing it.

Chapter 2, The Unity Interface, examines Unity's primary views, windows, layouts, and the toolbar. The interface components covered in this chapter are the ones used most often.

Chapter 3, Designing the Game, covers the design of the book's featured game—Cucumber Beetle. The game design includes gameplay, game mechanics, the player character, the non-player characters, game assets, animations, and more. Screen mock-ups and narratives are used to document the game's design.

Chapter 4, Creating Our Terrain, features the creation and customization of game terrain. Shaping tools are introduced, and water and vegetation features are added to the game environment.

Chapter 5, Lights, Cameras, and Shadows, explores cameras and lighting in Unity. The chapter starts with a look at cameras to include perspectives, frustums, and Skyboxes. The use of multiple cameras to include mini-maps is covered. Different types of lighting, reflection probes, and shadows are also explored.

Chapter 6, Creating and Importing 3D Objects for Our Game, focuses on making the game environment more robust, and trees and other objects are added to the game scene. This chapter also examines the steps necessary to create 3D objects using Unity's native modeling tools. Assets are added to the game from the Unity Asset Store and from 3D assets prepared specifically for the Cucumber Beetle game.

Chapter 7, Implementing Our Player Character, incorporates the game's player character—the Cucumber Man. The character is imported, and the controls and animations are reviewed. By the end of the chapter, the game will be ready for testing in the game mode.

Chapter 8, Implementing Our Non-Player Characters, explains the non-player characters—the Cucumber Beetles. The beetles' 11 animations are examined and changes are made to the non-player character's animation controller. In addition, scripts will be written to control the non-player characters. Also, in this chapter, cucumber patches, cucumbers, and cherries are added to the game world.

Chapter 9, Adding a Heads-Up Display, covers the design and development of, and how to incorporate, a Heads-Up Display (HUD) in the game. A canvas is used to create text and graphics that provide visual indicators of points, health, and additional information to help the player maintain situational awareness during game play. A mini-map is also implemented.

Chapter 10, Scripting Our Points System, looks at the design, scripting, and implementation of the game's point system. This includes providing frame-by-frame updates to key onscreen components of the game's HUD.

Chapter 11, Scripting Victory and Defeat, dives into the design and scripting of the game's victory and defeat conditions. Scripts will be updated to manage the Cucumber Man's health, provide frame-by-frame onscreen updates, and ensure that a player life is lost when the health runs out. Character lives and respawning are also covered.

Chapter 12, Adding Audio and Visual Effects to Our Game, demonstrates the plan and implementation of audio and visual effects in the game to help enhance overall game play. Specifically, audio is added to the key events in the combat system and several special effects, using Unity's particle system, are added to the game.

Chapter 13, Optimizing Our Game for Deployment, discusses optimization and deployment. The steps required to diagnose Unity games for performance problems are explored, in addition to how to optimize scripts and graphic rendering. The Unity build process is explained along with how to create a standalone player and how to deploy games for multiple platforms.

Chapter 14, Virtual Reality, examines Unity's capabilities with regard to virtual reality. An introduction to Virtual Reality is provided, including the hardware requirements. you will learn how to create a Virtual Reality game using the Unity game engine.

To get the most out of this book

You do not need to have experience of programming, working with game engines, or knowledge of Unity to benefit from this book. No assumptions have been made regarding knowledge or experience.

The only software requirement is downloading and installing the Unity game engine. Those steps are detailed in the book, so no software is required before you start reading.

Download the example code files

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit 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
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  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 In case there's an update to the code, it will be updated on existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at 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:

Conventions used

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

CodeInText: 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: "Ensure the Skybox folder is selected in the Project panel"

A block of code is set as follows:

public AudioSource audioSource;
public AudioClip eating;
public AudioClip attack;
public AudioClip die;

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 Fill option from the HUD_canvas."


Warnings or important notes appear like this.


Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please 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, 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


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