Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building an FPS Game with Unity
Building an FPS Game with Unity

Building an FPS Game with Unity: Create a high-quality first person shooter game using the Unity game engine and the popular UFPS and Probuilder frameworks

eBook
$39.99 $27.98
Print
$48.99
Subscription
$15.99 Monthly

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 Black & white paperback book shipped to your 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
Buy Now
Table of content icon View table of contents Preview book icon Preview Book

Building an FPS Game with Unity

Chapter 1. Getting Started on an FPS

Welcome to Building an FPS Game with Unity! This chapter is dedicated to offer a brief overview, from a beginner's point of view, of the exciting world of Unity development for the creation of a First Person Shooter (FPS) title, leveraging the powerful Ultimate First Person Shooter (UFPS) framework by VisionPunk and Prototype/ProBuilder 2.0 by ProCore3D. But, before we get started, we first need to get all of the resources we'll need and set up our project for success.

Over the course of this book, we will be creating a 3D FPS game similar to the popular games in the market such as Call of Duty: Black Ops III and Halo 5: Guardians.

We will learn how we can create custom weapons of our own as well as how we can create interior and exterior environments. After creating our environments, we will populate them with different combat encounters for players to fight as well as include intractable objects such as exploding barrels. We'll then customize our user interface using Unity's new GUI system before we package our game and create an installer to get the game out into the world!

This project will be split into a number of tasks. It will be a simple step-by-step process from the beginning to the end. Here is the outline of our tasks:

  • Project creation

  • Getting started with Unity's Asset Store

  • Installing UFPS

  • Installing Prototype

  • File organization

  • Customizing Unity's layout

Prerequisites


Before we start, we will need to get the latest Unity version. You can always download it from http://unity3d.com/unity/download/. At the time of writing this book, the page looks like this:

Once you get to this page, click on the CHOOSE YOUR UNITY + DOWNLOAD button (this page onward, I will be using the PERSONAL EDITION version). Then, click on the DOWNLOAD INSTALLER option.

The download assistant should be installed from your default downloads directory. Once it is installed, double-click on the file to open it.

Once there, go through the installation using the default properties. At the time of writing, we are using Unity 5.0.0f4, but most things should work with minimal changes but be sure to check out the book's website to check for any errata.

Since it needs to download Unity, this process may take some time.

Project creation


At this point, I assume that you have freshly installed Unity and have started it up. Follow these steps to create a new project in Unity:

  1. With Unity started, go to New Project. Enter a Project Name value such as FPS Game - Chapter 1 as that's what we are making and the chapter we're making it for, or whatever you want to call your project. Select Location of your choice somewhere on your hard drive and ensure that you have your game set to 3D. Once completed, select Create project. At this point, we do not need to import any packages as we'll be doing it manually.

  2. Here on, if you see the Welcome to Unity pop up, feel free to close it as we won't be using it. At this point, you will be brought to the general Unity layout, which should look as follows:

Note

I'm assuming you have some familiarity with Unity before you read this book. If you want more information on the interface, please visit http://docs.unity3d.com/Documentation/Manual/LearningtheInterface.html.

Getting started with the Asset Store


Since Unity 3, the Asset Store has been similar to Apple's/Android's app stores, except, instead of apps, you can buy prebuilt assets that can be imported directly into your project. We will be using this in our project; but, before we do so, we will need to have an account, that can be created using the following steps:

  1. To open the Asset Store via Unity, we can go to Window | Asset Store from the top toolbar.

    Note

    You may also open the panel by pressing Ctrl + 9 (command + 9 on Mac). If nothing happens, make sure Unity is focused on window by clicking on the program and trying again. If you prefer working outside Unity, you may also go to the Asset Store website at https://www.assetstore.unity3d.com/. However, you'll need to download assets from Unity via the Download Manager, which you can learn about from the link given later in this chapter.

  2. Next, go to the top-right corner of the panel and click on the Create Account button. Fill out your information and click on Create account at the bottom of the screen.

  3. You should receive an activation e-mail shortly after you submit the form. Open it and click on the activation link provided to verify your account.

  4. Once this is done, go to Log In from the top-right corner of the panel and enter the information you put in when you created the account. If all goes well, the top-right corner of the window will change to reflect that you are logged in.

With this, we can download and purchase assets from the Asset Store!

Note

Do not be concerned if you do not see 11 by your account, it just shows that I have a Unity Pro account.

For more information on the Asset Store and how to navigate using it, visit http://docs.unity3d.com/Manual/AccessNavigation.html.

Installing UFPS

Creating a game completely from scratch takes a considerable amount of time. Creating a first-person shooter relies on having a lot of knowledge as well as problem solving with things such as physics, mathematics, graphics, and programming. Now, books of each of these subjects could have been written based on it; but we are assuming that you want results in the fastest amount of time possible.

Rather than taking the tens of thousands of hours it would take to create it from scratch, we will leverage the very popular Unity add-on UFPS (Ultimate FPS) from VisionPunk. It will give us a solid foundation to create our own project with hundreds of parameters, which we can customize to create a project exactly the way we want it to be.

It's important to note that UFPS does cost money. But considering that a solid game programmer generally makes $50 or more an hour, the amount of time saved really makes it a worthwhile investment.

Now that we are logged into the Asset Store, let's purchase and install UFPS:

  1. Now, from the search bar directly below the login information, search for UFPS. You should see an icon that looks similar to the following:

  2. Click on the first option, which will bring you to the following page:

  3. Now, click on the Buy button and purchase the asset. Once it is purchased, the screen will change the Buy button to a Download button. You can click on it to download the asset and bring it into your project.

  4. Once it is downloaded, an Importing package window will open, giving you the option to choose which parts of the package you wish to import. We want everything, so just click on the Import button.

    Note

    If, for some reason, you get an error (the bottom bar, or Console, in the Unity interface) while importing that says something like 'Fatal error! getManagerFromContext:…". This is a bug in Unity due to the large file size UFPS has. Just Quit and continue with the import once again, when you restart Unity.

  5. Once the project is imported, close the Asset Store window and go back into the Unity Editor. From there, go down to the Project tab in the bottom-left corner of the screen and double-click on the UFPS folder. Go to Base\Content\Levels\SkyCity and double-click on the SkyCity file to open an example level. Then, press the Play button at the top-center of the project to start the project!

With this, we know that UFPS is installed correctly!

Installing Prototype


In general, creating levels in Unity is a painful experience. You have to type in the values for each piece that you want to add or you have to create everything inside a modeling program and import it, which will require you to have 3D modeling skills.

Other game engines have tools like Binary Space Partitioning (BSP) or Constructive Solid Geometry (CSG), which allow you to build geometry from scratch and apply materials to it to create areas for play. Filling in the gap that Unity has, ProCore3D has created a toolkit that allows for in-editor construction.

We will later on use ProBuilder to polish up our final product; but, in the meantime, we will use Prototype, their free version to build the basic structure and flow of our levels without wasting time, thus making things visually appealing until we polish it. Perform the following steps to install Prototype:

  1. Open the Asset Store once again by going to the toolbar, searching for Prototype, and looking for the following icon:

  2. Click on the first option in the top-left corner and you should be brought to a page like the following one:

    Tip

    After the writing of this book, Prototype will in the near future be replaced by ProBuilder Basic which is still 100% free but has additional features. I've talked with the creators about this, and they've confirmed with me after reading the book that everything discussed here should still work with the new version. For more information on this, check out http://www.protoolsforunity3d.com/probuilder/.

  3. Click on the Download button and wait for it to finish. Then, import the entire package by clicking on Import.

  4. We will now test it out to see whether everything is imported correctly. Create a new scene inside Unity by going to File | New Scene. Once there, press Ctrl + K to create a new cube using Prototype.

With this, we know that it was installed correctly! It may look pretty simple now, but we will be diving even more into using these tools later on.

Note

For more information on Prototype, check out http://www.protoolsforunity3d.com/prototype/.

File organization


Keeping your Unity project organized is incredibly important. As your project moves from a small prototype to a full game, more and more files will be introduced to your project. If you don't start organizing it from the beginning and keep planning to tidy it up later on, things may get quite out of hand as the deadlines keep coming.

Setting up a project structure at the start and sticking to it will save you countless minutes in the long run. It will only take a few seconds and is what we'll be doing now.

  1. Go to the Assets folder from the Project tab in the bottom-left corner of the screen. Once there, click on the Create drop-down menu. Click on Folder and you'll notice that a new folder has been created inside your Assets folder.

    Tip

    Similarly, you can right-click on the negative space within the Project window to create a folder.

  2. After the folder is created, you can type in the name of your folder. Once it is named, press Enter. Let's now create a folder called MyGame. We also need to create folders for the following directories inside the MyGame folder:

    • Prefabs

    • Scenes

    • Scripts

Note

If you happen to create a folder inside another folder, you can simply drag and drop it from the left toolbar. If you need to rename a folder, just simply click on it once and wait, you'll be able to edit it again. Alternatively, on the keyboard you can press F2.

Your project should now look like this:

Customizing Unity's layout


While working with Unity in this book, I will mostly be using its default layout. If, for some reason, your layout does not look like the earlier screenshot, you can reset it by going to the top-right corner of the window and selecting Layout | Default.

You can customize the layout by clicking and dragging any tab to wherever you want it to be. There are also additional options such as making the Project tab use a one-column layout by right-clicking on the tab and selecting One Column Layout. Sometimes, I like to split the center with the Scene tab on one side and the Game tab on the other, so I can see how things change from a different angle. For those of you with multiple monitors, you may use a monitor just for the game. It's all up to your preferences, but keep your changes in mind, as I'll assume that you'll be using Default.

Note

For more information on customizing your Unity layout, check out http://docs.unity3d.com/Manual/CustomizingYourWorkspace.html.

Summary


Hopefully, you've enjoyed taking the first few steps toward becoming an FPS game developer with Unity! In this chapter, we learned how to create a project inside Unity 5. We then learned how to create an account and navigate the Unity Asset Store. After this, we learned about UFPS and Prototype and installed them. Finally, we touched upon file organization and customized Unity's layout.

In the next chapter, we will delve deeper into using Unity Editor and UFPS by creating our own custom weapons!

Left arrow icon Right arrow icon

Key benefits

What you will learn

Use UFPS to build custom weapons with custom meshes and behaviors Explore level design as you prototype levels, making use of Prototype to build levels out quickly Build environments that are realistic as possible while keeping peak performance and repetitiveness down Review tips and tricks on how to create environments using both terrain for outdoor areas and a modular workflow for interiors Develop a number of different encounters that your players can fight against, from a simple turret enemy to complex AI characters from Shooter AI Discover how to create unique objects such as exploding barrels and objects you can interact with Create a custom GUI to help your game stand out from the crowd Package your game for release, create an installer, and get your game out into the world
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected

Publication date : Oct 30, 2015
Length 326 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781782174806
Vendor :
Unity Technologies
Category :

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 Black & white paperback book shipped to your 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
Buy Now
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details


Publication date : Oct 30, 2015
Length 326 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781782174806
Vendor :
Unity Technologies
Category :

Table of Contents

18 Chapters
Building an FPS Game with Unity Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
Foreword Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
Acknowledgment Chevron down icon Chevron up icon
About the Reviewers Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
1. Getting Started on an FPS Chevron down icon Chevron up icon
2. Building Custom Weapons Chevron down icon Chevron up icon
3. Prototyping Levels with Prototype Chevron down icon Chevron up icon
4. Creating Exterior Environments Chevron down icon Chevron up icon
5. Building Encounters Chevron down icon Chevron up icon
6. Breathing Life into Levels Chevron down icon Chevron up icon
7. Adding Polish with ProBuilder Chevron down icon Chevron up icon
8. Creating a Custom GUI Chevron down icon Chevron up icon
9. Finalizing Our Project Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Top Reviews
No reviews found
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