Book Image

Building an RPG with Unity 2018 - Second Edition

By : Vahé Karamian
Book Image

Building an RPG with Unity 2018 - Second Edition

By: Vahé Karamian

Overview of this book

In a role-playing game (RPG), users control a character, usually in the game's imaginary universe. Unity has become a top choice for developers looking to create these kinds of immersive RPGs. Building an RPG with Unity 2018, based on building some of the most common RPG features, teaches you tips, tricks, and techniques that can be applied to your own game. To start with, the book guides you through the fundamentals of role-playing games. You will learn the necessary aspects of building an RPG, such as structuring the game environment, customizing characters, controlling the camera, and designing other attributes such as inventory and weapons. You will also explore designing game levels by adding more features. Once you have understood the bigger picture, you will understand how to tackle the obstacles of networking in Unity and implement multiplayer mode for your RPG games. By the end of the book, you will be able to build upon the core RPG framework elements to create your own immersive games.
Table of Contents (16 chapters)
Title Page
Copyright and Credits
Packt Upsell


Everyone wants to make a game—today, this is possible more than ever due to the democratization of the game industry and the tools that are used to design and develop games. This book is written with several purposes in mind. During the process of writing this book, Unity went through several major updates and releases. At the time of writing, Unity stands at version 2018.1.1f1, and the new release has added many great features to the game engine. Simply put, it is impossible to cover everything in one single book!

This book is intended as a reference guide for individuals who want to learn about Unity and apply their skills for the creation of a Role-Playing Game (RPG).

Who this book is for

This book is written for individuals who want to learn and apply their Unity skills for the creation of an RPG. It is assumed that the reader has a basic understanding of the concepts of programming and is comfortable with the basics of Unity's IDE. This book gives a strong and solid foundation of the core concepts and topics that can be applied to build your own game experience.

What this book covers

Chapter 1, What is an RPG?, provides a good background of what an RPG is. It covers some historical aspects and gives examples of existing RPGs. It discuss the main aspects of an RPG, covers some terminology, and prepares the reader for the rest of the book.

Chapter 2, Planning the Game, is where we take a look at character definitions, character class attributes, character states, and how to set up and rig character models, which includes an exploration of motion, controllers, and inverse kinematics.

Chapter 3, RPG Character Design, continues expanding on player character customization and looks at preserving character states, the setup of Non-Player Characters (NPCs), and introducing NPC Artificial Intelligence (AI) and interaction.

Chapter 4, The Game Mechanics, is where we start planning the game. We discuss the different types of assets and resources we will need during the creation of our game, introduce a third-person character controller, and create our initial level and scripts. We also take a look at the Terrain Toolkit for terrain generation.

Chapter 5, GameMaster and Game Mechanics, looks at enhancing the Game Master script, introduces Level Controller and Audio Controller scripts, discusses the storage of character data and the character customization state, and explores options for the initial user interface for the main menu.

Chapter 6, Inventory System, covers the creation of a generic inventory system; the creation of the necessary scripts, assets, and prefabs that represent the inventory items; designing the inventory user interface; and how to represent the inventory system and its items.

Chapter 7, User Interface and System Feedback, discusses the design and implementation of a heads-up display, player character information panel, and the active inventory items panel. The special inventory items panel is designed and implemented, as are the non-player character health bar and UI.

Chapter 8Multiplayer Setup, discusses multiplayer programming using Unity's Unet architecture. This chapter illustrates the concepts using two sample projects. The initial project is a tank game that illustrates the concepts of server client and data synchronization. The second project applies what we have learned to create a scene supporting our character models.

To get the most out of this book

You will need to have a good understanding of the C# language. You will also need to have a good understanding of the basics of the Unity IDE.

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 the 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: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

using UnityEngine; 
using UnityEngine.SceneManagement; 
namespace com.noorcon.rpg2e 

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 System info from the Administration panel."



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