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:
Getting started with Unity's Asset Store
Customizing Unity's layout
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.
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.
With Unity started, go to New Project. Enter a Project Name value such as
FPS Game - Chapter 1as 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.
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:
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.
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:
To open the Asset Store via Unity, we can go to Window | Asset Store from the top toolbar.
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.
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.
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.
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.
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:
Now, from the search bar directly below the login information, search for
UFPS. You should see an icon that looks similar to the following:
Click on the first option, which will bring you to the following page:
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.
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.
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.
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
UFPSfolder. Go to
Base\Content\Levels\SkyCityand 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!
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:
Open the Asset Store once again by going to the toolbar, searching for
Prototype, and looking for the following icon:
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/.
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.
For more information on Prototype, check out http://www.protoolsforunity3d.com/prototype/.
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.
Go to the
Assetsfolder 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.
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
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:
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.
For more information on customizing your Unity layout, check out http://docs.unity3d.com/Manual/CustomizingYourWorkspace.html.
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!