Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Building an RPG with Unity 2018
Building an RPG with Unity 2018

Building an RPG with Unity 2018: Leverage the power of Unity 2018 to build elements of an RPG. , Second Edition

eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Building an RPG with Unity 2018

Chapter 2. Planning the Game

In the previous chapter, you were given a good overview and historical background of RPG, and hopefully, it also sparked your imagination. In this chapter, we will start to lay the groundwork for our own RPG. We will start by defining the story of our game, as well as the plot and the quests that will make the game playable. We'll look at the assets that will be required to create our environment, characters, and finally, we'll design the levels.

The following is a breakdown of the topics we will be covering in this chapter:

  • Building our RPG
  • The story of the Zazar dynasty
  • Asset inventory
  • Level design
  • The awakening
  • Testing the level
  • Creating the main menu

Awaken your creativity and let your imagination go wild!

Building our RPG


As discussed, building a role-playing game is no small task, but once you start down the path, you will come to the realization that it is not as difficult as it seems initially. The idea is to get started, and as you put your ideas down on paper and start the design process, more and more ideas will come into perspective.

As we have learned, there are some key elements that we will need to establish for our RPG. Let's recall them, and maybe even fine-tune them as we go along.

Our game's key elements are as follows:

  • Story and setting
  • Exploration and quest
  • Items and inventory
  • Character action and abilities
  • Experience and levels
  • Combat system
  • User interface

The story of the Zazar dynasty


The premise of most role-playing games tasks the player with saving the world. There are often twists and turns as the story progresses, such as the surprise appearance of an estranged relative, or enemies who become friends and vice versa. We will create our story and game based on such a story.

Backstory

Once upon a time, there was a great kingdom, ruled by the great King Zazar. The ruler of the kingdom was a generous lord to his subjects. The kingdom under the rule of Zazar was peaceful and prosperous; however, over time, internal family rivalries and struggles caused cracks in the strong bond that kept the kingdom intact.

Due to mysterious events, the great king decided to move his family away from the kingdom and trust his son—who will become the player character—with one of the wise elders that he trusted. The kingdom was never the same... Until now!

Exploration and quests

Now that we have defined the setting for our game, we can start working on developing...

Asset inventory


Now is a good time to discuss some of the basic assets that will be required for the development of our RPG. Our game assets are defined by the scenes we describe for our game. For our RPG, we have described four unique scenes. Each one has been described in enough detail for us to get an idea of the types of assets we will require.

Environment assets

The general theme of our game will be medieval. There are several ways to go about this. The first and preferred way is to either create the environment models by yourself or a with a teammate; the second is to find a freely available model that has been created by a third party; and the third is to purchase 3D models created by a third party.

The Asset Store is a great place for you to start hunting for great content if you do not have the ability to create your own 3D models. You can use the Asset Store to search for medieval-themed environments that can be used for the game.

One of my favorites is called Medieval Environment...

Level design


Now that we have our game story on paper and have an idea of what we want to achieve, it is time to apply our skills to actually making it happen.

Note

Since this book targets an audience that is already familiar with the basics of Unity, we will not cover the fundamental aspects of the software.

To get started, we need to launch Unity. I am using the 64-bit edition of Unity 2017.x Pro. You do not need to have the Pro version of Unity to complete the project in this book. See the following screenshot:

Go ahead and select a location and a name you desire for your project, and click the Create project button. At this point, Unity will create an empty project for you and display the Unity IDE. It should look something like the following:

New project

Note

For better quality of images, download the graphics bundle from https://www.packtpub.com/sites/default/files/downloads/BuildinganRPGwithUnity2018_ColorImages.pdf

Your view might be a bit different, depending on how you have configured...

Testing the level


At some point, you will want to test out the level and look at it through the eyes of the camera. We can use the built-in third-person character controller that comes in the Standard Assets and do a quick walk-through of the level.

Note

If you did not import the Standard Assets when you created the project, you will need to import them by selecting Assets followed by Import Package|Characters.

In your Project window, you will see a folder called Standard Assets; there is a subfolder called Character Controllers. You will need to select the 3rd Person Controller Prefab and drop it somewhere on the current scene. A good location is next to the shack. Make sure that the 3rd Person Controller (3rdPC) is above the terrain so it does not fall through!

You will have to attach a Rigidbody component to the 3rdPC GameObject. This is needed to make sure that our player-character (PC) uses the built-in physics for collision detection.

Before you run the level, let's make sure the camera...

Creating the main menu


Now is a good time to create the starting point for our game. Go ahead and save the current scene. We will make a new scene that will be used as the starting point of our game. To create the new scene, you will need to select File | New Scene. Go ahead and save the scene. I called my scene MainMenu.

Now we have a clear canvas that we can work with to create our Main Menu. In the Hierarchy window, right-click and select UI | Panel. This will create a Canvas GameObject and an EventSystem GameObject, and place them in your Hierarchy window. You will notice that the Panel UI Object is a child of the canvas. All UI elements will be a child of a canvas. Your Hierarchy should look something like the following screenshot:

There are several key aspects that we want to make sure are set properly. These are namely on the Canvas GameObject. Select the Canvas GameObject and look at the Inspector Window.

For this particular canvas, make sure that the Render Mode is set to Screen Space...

Creating the GameMaster script


As discussed in Chapter 1, What is an RPG?we will need a way to manage our game. We will create a script called GameMaster. This will be the core of the game that glues everything together. As we progress with the book, you will see how we will modify the core to meet our needs.

For now, we are just going to create a simple C# script and name it GameMaster.cs. We will then create the code that will be used to handle some of the basic events we want to perform at this point, namely, navigating from scene to scene.

From your Project Window, under your scripts folder, right-click and select Create | C# Script. Name it GameMaster.cs. Double-click your script to start your code editor and place the following code in there:

using UnityEngine; using UnityEngine.SceneManagement; namespace com.noorcon.rpg2e { 
   public class GameMaster : MonoBehaviour 
   { 
 
// Use this for initialization 
      void Start() 
      { 
 
      } 
 
      // Update is called once per...

Summary


In this chapter, we have established a good sense of the RPG. We have defined our levels and the settings for each level, and defined clear objectives for each level and the outcome for each level. We also took the first level, called Awakening, and created the environment. We looked at how to use our assets and the Asset Store to incorporate 3D models in our scene. We also looked at how to plan the layout of the level. We introduced a third-person character controller into the scene to help us visualize how the level looks from the player's perspective and help us fine-tune it as needed.

Here is a list of the assets that were used for the design of this level:

  • For the terrain, I used the Terrain Toolkit 2017 asset
  • For the models within the level, I used the Medieval Environment Pack asset

By the end of the chapter, we also developed our Main Menu scene and our initial GameMaster script that will be used to glue the core of the game together. In the next chapter, we will start creating...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • •Get insights into Unity's user interface (UI) system and and build UIs for your RPG
  • •Implement artificial intelligence (AI) to build intelligent entities that take your game to the next level
  • •Develop multiplayer features for an RPG using Unity 2018

Description

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.

Who is this book for?

Building an RPG with Unity 2018 is for you if you are a programmer interested in developing and further enhancing your skills when developing RPGs in Unity 2018. This book does not cover the basics of Unity, and so is for intermediate or more advanced users.

What you will learn

  • •Construct a framework for inventory, equipment, characters, enemies, quests, and game events
  • •Understand how to load and unload scenes and assets
  • •Create multiplayer game settings for your RPG
  • •Design a UI for user input and feedback
  • •Implement AI for non-character players
  • •Customize your character at runtime
Estimated delivery fee Deliver to Egypt

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 30, 2018
Length: 366 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788623469
Vendor :
Unity Technologies
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Egypt

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

Publication date : Jul 30, 2018
Length: 366 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788623469
Vendor :
Unity Technologies
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 146.97
Building an RPG with Unity 2018
$48.99
Unity 2018 Artificial Intelligence Cookbook
$48.99
Unity 2018 By Example
$48.99
Total $ 146.97 Stars icon

Table of Contents

8 Chapters
What is an RPG? Chevron down icon Chevron up icon
Planning the Game Chevron down icon Chevron up icon
RPG Character Design Chevron down icon Chevron up icon
The Game Mechanics Chevron down icon Chevron up icon
GameMaster and Game Mechanics Chevron down icon Chevron up icon
Inventory System Chevron down icon Chevron up icon
User Interface and System Feedback Chevron down icon Chevron up icon
Multiplayer Setup Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8
(9 Ratings)
5 star 55.6%
4 star 11.1%
3 star 0%
2 star 22.2%
1 star 11.1%
Filter icon Filter
Top Reviews

Filter reviews by




Kristin Dragos Sep 10, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book is a great overview of the RPG genre! Covers all the core aspects of an RPG and how to build them - from planning to implementation. It even recommends some assets to jump start your development!
Amazon Verified review Amazon
S. Isayan Sep 16, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
1. Well written easy to follow step by step guide.2. Practical examples.3. Low cost.4. Just buy it already.
Amazon Verified review Amazon
Jeff Sep 12, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Does a great job going from 0-100 on everything you need to know to get started. A chapter is dedicated on how to plan building your game. Too many times people skip this important step to plan all the little details and then have to make changes later and pushing back your release date. This book covers just about everything you need to get your feel wet and learn, including lots of code, illustrations, pictures, and examples.
Amazon Verified review Amazon
NeverRight Sep 08, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you are looking for a beginners guide to the development of Role Playing Games then this is the perfect book for you.1- Has good explanation on what a role playing game is and how many types of patterns you can follow to design one.2- Step by step explanation of different modules of a Role Playing Games with real life examples.3- Nice introduction to environment design.4- One of the best implementation of locomotion and combat systems.5- Easy to follow instructions for structing your code and making the game multiplayer.This book let you master the fundamentals of developing a Role Playing Game. Highly Recommended.
Amazon Verified review Amazon
Nemesis Dec 13, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is best for young biginers who are new to game dev code .
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela