Welcome to Unreal Engine 4 (UE4)! Unreal Engine can make developing your own games simple, even for those of you with no prior programming experience. But, it is important to familiarize yourself with some of the major systems to save yourself time and headaches down the line. This book will get you up to speed with the major features of UE4 quickly, and leave you with the resources required to expand on your knowledge through other tutorials and official documentation.
This book is intended for people with some previous programming experience. I won't go into detail about how variables and functions work, but I will explain how UE4 uses them with the Blueprint system. We will go into more detail about some systems that are specific to game programming or to the UE itself, such as UMG and multiplayer.
We will use examples to learn. Each chapter will build and expand on a working game. It won't be anything fancy, but you'll be able to see how UE4's systems interact by means of a working example.
In this chapter, we will cover the following topics:
- Downloading and installing the Unreal Engine
- Using Project Templates to save time developing basic functionality
- Explore the layout of the editor so we know where to find what we need in order to develop our game
- Examine the settings we can use to fully customize our game and the editor itself to save development time
- Adding plugins and marketplace items to further expand your development possibilities
So with that, let's get started!
Before we get into the engine itself, we need to download and install it as follows:
- Search the internet for Unreal Engine, or head to this address at https://www.unrealengine.com.
- Create a free account with Epic Games and log in to it.
- In the top right of the Unreal Engine site, you will find a link to the download. Download the Epic Games launcher.
- Once it's done downloading, go ahead and install it.
- Once that's done, open it up. This will load the Epic Games launcher.
- When the launcher opens, click the Unreal Engine button on the left-hand side:
- Here, you will have four useful tabs at the top:
Here is a description of the items you can see in the preceding screenshot:
- Unreal Engine: In addition to featured content, there are links to AnswerHub (like Stack Overflow, but UE4-specific), Forums, and a Wiki, with tutorials and engine documentation. There are also links to the Roadmap and Blog to see current and upcoming developments involving the engine.
- Learn: This is a more detailed tab for developers to find tutorials and documentation. This tab also includes demos and other samples. This is a great place to find inspiration for features that might otherwise not have been on your mind.
- Marketplace: This is the UE asset store. Art, code, animation, and plugins can all be found here. There is a free section to get you started, and frequent sales, so keep an eye on it!
- Library: This tab keeps track of your currently installed engine versions, your projects, and your marketplace purchases for easy installation.
- This Library tab is where we will begin. You can choose to install any engine version all the way back to 4.0.2, but, for the purpose of this book, we will be using the latest version, which is 4.22.1 at the time of writing.
- To start the installation, press the plus sign next to Engine Versions and select 4.22.1 with the drop-down arrow, and then press Install:
Once that's done, the Install button should change to Launch, for example. For each project's initial setup, you'll press this button to launch whichever engine version you want the project to use. After that, the project will appear in your My Projects list and you can launch them that way. You can also right-click on a project in the My Projects list to create a shortcut for it. That way, you won't even need to run the Epic Games launcher to dive right back into your project.
For now, hit the Launch button on 4.22.1. The project browser will appear, as follows:
All of your existing projects will show in the Projects tab along with their engine version. Projects cannot be opened with a previous version of the engine, but it's usually fine to open a project with a later engine version.
You will just need to make sure any plugins your project uses will be compatible with the newer engine version.
In the New Project tab, you will find templates for various project types. These templates will give you a great head start, so you won't need to reinvent code that is common to specific game types. The templates are as follows:
- Blank: Only use this option if none of the following templates fit your project's genre. Usually, one of the other templates will cover what you need to get started, and everything about the template can be customized or deleted. But if your game project doesn't fall under anything else, you can use this option to create your entire game from scratch.
- First Person: This is the standard shooter template. It includes a first person arm mesh and a weapon that fires projectiles.
- Flying: This is a third-person view of a spaceship that can be flown around.
- Handheld AR: This includes everything you need to get started with augmented reality on a phone. Make sure your device supports ARKit for iOS devices, or ARCore for Android!
- nDisplay: This option is used for multimonitor/cave display setups. It is rarely used, but is an incredibly useful template when you need it.
- Puzzle: Most people associate the UE with top-of-the-line graphics, but even simple puzzle games can benefit from the workflow that Blueprints present.
- Rolling: Ball-based games will find their home here. All of these templates have keyboard, gamepad, and touch inputs already set up as appropriate. Here, the ball can be controlled with any of the three options.
- Side Scroller / 2D Side Scroller: This is a standard Metroidvania camera setup. Which of these two you use depends on whether your art assets will be 2D or 3D.
- Third Person: This is a free rotating camera with a keyboard-controlled player, common for platformers and action games.
- Top Down: This can be easily confused with the Third Person template, but this one has a fixed camera with a Diablo style click-to-move player.
- Twin Stick Shooter: This is the Top Down shooter template. Don't let the icon fool you; this template is just as suitable for a Hotline Miami style human player as it is for a bullet-hell spaceship one.
- Vehicle: This is the racing template. Another great feature of these templates is the ability to combine them. For instance, if you wanted to make a GTA style game where you could run around or drive cars, you could choose the Third Person template, and once you're in the Unreal editor, you could add the Vehicle template to your project as well.
- Virtual Reality: This includes hand models, teleportation, and grabbable objects.
- Vehicle Advanced: If your project needs more realistic vehicles than the simple physics of the vehicle template, this would be your choice.
Most of these templates can be used in both Blueprint and C++ projects (augmented reality (AR) and virtual reality (VR) templates are Blueprint only). Unless your goal is to solely use Blueprints or C++, don't worry too much about which project type to use. C++ can be added to Blueprint projects and vice versa.
One major exception to this is if you need to alter any of the engine code itself, or if you need dedicated servers for your game. Using the UE through the launcher with the official engine versions allows us to extend from the engine and its classes, but it doesn't let us modify the engine code directly. If you do need to do this, you will need to download and compile the engine yourself, which is fairly simple but outside the scope of this quick start guide. Most of the time, you can create and deploy your entire game without needing to touch the engine code.
For this book, we will be using a Blueprint project with the Third Person template, so select that.
Next, we need to choose from a few other options. These can also be changed later, so don't worry about choosing incorrectly. Here are the selections we need to make:
- Desktop / Console or Mobile: For this book, we will be using Desktop / Console as our target hardware.
- Maximum Quality or Scalable: We will use Maximum Quality here. Graphics settings can be changed once the project is created, and we will discuss some of those options later in this chapter.
- With or Without Starter Content: Most of the time, you'll want to include the starter content for quick prototyping. These assets can always be deleted from your project once they're no longer needed, but they are a great help when creating test levels:
Now, give your project a name and location and click Create Project. I will be naming the project AwesomeGame, because we're awesome and your game will be awesome:
Now, we have to wait while the project is being created. This will take a while, and it might seem like it gets stuck at 90-something percent, but give it time and eventually, we'll get our first look at the editor!
Once the editor finishes loading, we will get our first look at it. This is what we will see:
The editor's layout will quickly be decipherable to anyone who has used Unity or another game engine before, but there's always the fear of clicking something and having everything go wonky, so let's take it panel by panel. We'll start at the bottom left with the Content Browser.
This is where all of our game's content will appear, from code to static meshes, materials, sounds, and animations. If we press the arrow button in the top-left corner above the folders, we can see a complete folder view for the content in our project, as shown in the following screenshot:
To get a quick overview of the template you're using, you can press the play icon on the ThirdPerson Overview asset (the ThirdPersonBP folder in our case) as shown in the following screenshot:
This will point you to the location of the important assets provided with that template. For the ThirdPerson template, the two assets we'll be digging into the most are the ThirdPersonCharacter and ThirdPersonGameMode under ThirdPersonBP\Blueprints.
At the end of the overview, a Tutorials tab will pop up with links to tutorials for everything from C++ to animation and landscapes. You can also find a link to this tab under Help | Tutorials.
Back to the Content Browser, if you look at the top, you'll see the Add New button. This lets you create a new asset of any type, including Blueprints, behavior trees for AI, and sound cues. At the top of this list, you'll see Add Feature or Content Pack, which is what I was describing earlier in this chapter in the Using project templates section. If you require Vehicle template functionality in your ThirdPerson project, for example, this is where you would add it.
Next in our tour of the Unreal editor is the Viewport. This displays our currently loaded level and can be configured to make navigation easier. There are two ways to move the camera around in the Viewport:
- Mouse and WASD: Holding the right mouse button down will let you rotate the camera, while using the WASD keys will move the camera forward/backward and left/right. Anyone with experience in Unity will be used to this camera movement.
- Mouse only: It is also possible to navigate using only the mouse, which people with experience in previous Unreal editors will be familiar with. Holding the left mouse button will let you move the camera along the horizontal plane along with looking left/right. Holding the right mouse button will keep the camera in place while letting you look around. Holding both the left and right mouse buttons will let you move the camera up/down and left/right at the same time while keeping the rotation the same. Combining these three mouse button combinations will let you navigate a level without needing to use the keyboard.
On the upper left of the Viewport are a few drop-down menus that let us customize and configure the Viewport. Starting from the left with the drop-down arrow, a few of the important options are as follows:
- Realtime: This toggles real-time rendering of any animated elements of the level. You can see it with the spinning green DocumentationActor, but this also applies to any animated materials and particle effects. With this off, elements will only update while you are moving the camera.
- Show Stats / Show FPS: This toggles frames per second (FPS) and stats that show information such as poly counts, rendering times in milliseconds, and memory usage. A full list of stat options can be found in the Stat submenu a bit further down the menu.
- Game View: This toggles any editor-only icons and assets so you can see what the level will look like in game. Pressing G also toggles this, so if you've accidentally hidden the editor icons, it was probably this way.
- Bookmarks: This allows you to set bookmarks for camera locations so you can use keyboard numbers to teleport there. This option is incredibly useful and often overlooked, so getting into the habit of using these early can save you a lot of time navigating your levels. These are level-specific, making them even more useful, but don't forget to save your level if you change these; otherwise, you will lose them.
- Layouts: This lets you choose from a variety of Viewport layouts with up to four views. If, for some reason, you need even more Viewports, at the top of the editor, press Window | Viewports and select one of the other Viewports (Viewport 1 is the existing one). Each of these can also be configured with up to four panes.
- Advanced Settings: This lets you further customize the Viewports by inverting the mouse, combining the translate/rotate widgets, and adjusting highlight intensity, among other things. Don't worry about messing things up here; you can always press the Reset to Defaults button in the top-right corner.
Next to the drop-down arrow at the top of the Viewport is Perspective. This is the setting for the Viewport type. By default, it shows a 3D perspective, but this can be configured to show a 2D wireframe view from the top or left, and so on.
Navigation while in a 2D perspective is a bit different than the 3D view. Holding the right mouse button lets you move around, and the mouse wheel lets you zoom in and out.
While in a 2D view, holding the left mouse button lets you drag a selection box. Another useful tool is holding the middle mouse button to use the measuring tool. This is useful for programmers when we're trying to figure out how far enemies should be able to see, for example.
Next in the Viewport options is the Viewport's visual style, which defaults to Lit. You can choose Unlit and Wireframe for example, but this also offers a lot of optimization views, such as Shader Complexity and Collision views. Most of these are more useful for artists.
The final dropdown in the upper-left corner is the Show list. This can be used to hide things that might be in your way, such as fog, or to show extra options, such as a collision. This includes a few advanced options, such as showing bones for skeletal meshes. This menu also includes a Default so that you can reset anything you've changed here.
In the upper-right part of the Viewport are the settings for the translation tool, grid, snap, and camera:
- The first three buttons (labelled 1 previously) allow us to switch between translation, rotation, and scaling for world objects (although it's easier and quicker to use W, E, and R on the keyboard for this).
- Next is the global/local toggle (2). This changes the way the translation, rotation, and scaling work to be world oriented or dependent on the selected object's rotation.
- The next setting is the grid snap (3). The first button of these three (with a curve and three arrows) lets you toggle surface snapping, which will automatically place objects on the floor when moving them around, with an option to automatically rotate them to align with the floor's rotation.
- The next button (section 3, second button), which is orange with a grid, toggles grid snapping completely. If you need to precisely align an object, turning grid snapping off will help with that.
- The final button in the grid snap section (section 3, third button) lets you choose the grid snap distance. Lower values will let you adjust objects more finely.
- After the grid snap, we have the rotation snap (4) and scale snap (5) sections. They operate the same as the grid snap, and the scale snap has an additional option to preserve the ratio between the axes while scaling.
- The last option in the upper right of the Viewport controls the camera speed (6), with a scalar for more control over the range of speed.
Above the Viewport is the toolbar, as shown in the following screenshot:
This gives access to some of the more commonly used features of the editor:
- Save Current: This saves the current level. Save on a frequent basis. By default, the editor has autosave turned on, but it's set to 10 minutes, and that can be a lot of work when you're in the zone.
- Source Control: This hooks your content to subversion, perforce, or Git content control. If your team uses one of these, this will save a lot of time over having to do this outside of the editor.
- Content: This opens the Content Browser if you have that tab closed.
- Marketplace: Pressing this may seem like it does nothing, but it opens the Marketplace in the Epic Games launcher. You'll need to switch over to that program to see it, as it doesn't automatically pop back up.
- Settings: This provides access to some settings menus we'll be talking about in a bit, along with a number of selection, quality level, and snap settings for the Viewport.
- Blueprints: This lets you create and find Blueprint classes, but this is easier done in the Content Browser. This is also where you access the level-specific Blueprint.
- Cinematics: This is beyond the scope of this guide, but here is where you would get started with creating cinematics at your level.
- Build: Here is where you set the rebuild options for the level, and where you rebuild geometry, lighting, and pathing in the level. For programmers, most of this is not our focus, but you will want to rebuild pathing when working with AI, and doing a complete rebuild by simply pressing the Build button in the toolbar will get rid of the red LIGHTING NEEDS TO BE REBUILT notification in the Viewport and in game. To make things quicker, keep the Lighting Quality at Preview until you're ready to do non-test builds.
- Play: This lets you play the current level without having to build the entire project. By default, this uses the current Viewport, but exiting from this with Esc doesn't reset the camera, so I usually set this to New Editor Window. For multiplayer testing, you can also set the number of players, which will open a separate window for each one. If you have compiled the engine yourself and set up dedicated server functionality, you can enable that here as well. At the bottom is a link to Advanced Settings, such as mouse control, Viewport sizes, and server options.
- Launch: If you are developing for mobile or browser, you can launch to those devices from here.
The World Outliner tab on the right of the editor window contains a list of all of the objects in the current level, as shown in the following screenshot:
You can group them into folders, right-click to create a new folder, and click the eye icon on the left to hide individual objects or an entire folder at once. Selecting one or more objects here will display their properties in the Details panel (discussed in the next subsection). The right column will also have links to directly open the Blueprint associated with an object if it has one (such as the ThirdPersonCharacter for our project).
You can double-click on an item here to zoom the camera to that object. If you have an object selected, clicking it again will allow you to rename it to make organization easier.
This panel also has a Search... bar, which makes finding objects easier, especially combined with the renaming feature.
Right-clicking on an object in this panel provides more options for that object, including visibility, selecting matching objects, and attachment options. This same menu appears when you right-click on an object in the Viewport.
When an object is selected in a Viewport or in the World Outliner panel, its properties appear in the following screenshot:
Here, we can adjust each individual object in the level's properties. Most commonly, we can perform the following actions:
- Manually set Location/Rotation/Scale if we need precise values
- Set or find materials, meshes, and so on that it uses in the Content Browser (click the magnifying glass icon to go to that asset in the Content Browser)
- Adjust physics and lighting properties for that object (if it does not need to cast shadows for instance)
- Toggle visibility for the object so it appears in the editor but not in game (under the Rendering section of its properties)
- Adjust any custom properties we've added to our own objects (discussed in Chapter 2, Programming Using Blueprints)
Keep in mind that some of these properties are more easily changed without needing to do it here. For instance, for the material property of a static mesh, you can simply drag the material from the content browser on top of the object in the Viewport. You don't need to use the arrow button in the object's properties unless the object has multiple materials and you're having difficulty while setting up the right one.
Most of these properties aren't used too often, but there are a few here that interest us:
- Enable World Composition: For open world style games, this option would need to be enabled. Epic Games has good resources for creating this type of world. Searching for UE4 World Composition will provide you with plenty of tutorials for that.
- KillZ: This is the height at which actors get destroyed. If you're creating a level with a lot of height and your character keeps disappearing when you drop down, check this value to make sure it's low enough. It will appear as a red line in any of the side/front Viewports.
- GameMode Override: Instead of using the default GameMode class (which we will discuss with other Project Settings shortly), each level can override that with a specific GameMode class. For example, if you were making a third-person game, but one level was a car race, you could use this to set specific rules and character/HUD classes for this level, instead of needing to integrate both types of gameplay into one GameMode class. Once a GameMode override is set, each individual class default can be edited in the Selected GameMode dropdown beneath it.
- Override World Gravity: As withGameMode, instead of using the Project Settings value for gravity, each level can have its own.
Next, we will take a look at how to customize the editor itself with editor preferences to make our workflow easier.
Back in the main editor window, if you go to Edit | Editor Preferences (near the bottom), you will see options to customize a lot of things pertaining to the editor. Let's go over some that are used more often:
- In the Appearance section, you can change the color of the grid and selected items, set colorblind options for the editor, and change the font size and color for the log.
- The Keyboard Shortcuts section has a complete list of the keyboard shortcuts the editor uses in its various windows and modes, and they are all completely customizable. Spend some time familiarizing yourself with them, as they will save you a lot of time when working on the editor.
- Next is the Loading & Saving section. Earlier, we talked about the autosave feature, and here is where you can change how it operates. By default, it is set to 10 minutes, but you can change that time here in the Auto Save section. You can also change what happens when you start up the editor as far as which level is loaded, and if it should restore any asset tabs you had open when you last shut down, which is pretty useful if you're working in a lot of different classes at a time and don't want to lose your place.
- Another section that you will want to take a look at is the Play section under Level Editor. Here, we can customize the Play in editor settings as well as the new window settings, changing the window size and the mouse/keyboard control scheme.
- You might not want to change most of these settings right away, but don't be scared to try them out. All of the sections here have a Reset to Defaults button if you need to revert your changes. You should definitely come back to these settings once you've had some experience with the editor and know more about what changes can improve your workflow.
Next, we'll discuss the project settings under Edit | Project Settings:
The first section we'll talk about is Description. Here is where you will set your project/company name, any copyright and licensing notices, and window settings for the game (resizeable, borderless window, and so on). You can also manually set your project thumbnail here, which will show up in the Epic Games launcher in your project library.
Next up is Maps & Modes. Here, you can change the default GameMode class for your game (which can be overridden per level as previously discussed). You can also set which level is loaded when the editor starts up and which level is loaded when the actual game starts up (usually a title screen level).
There are also options for split-screen multiplayer if your game uses that.
The last option here is the GameInstance class, which can store data across level loads.
The next section is Movies, which allows you to set any startup movies, such as company logos, and lets you set whether or not these are skippable. And please, on behalf of gamers everywhere, make these skippable.
The next section is Packaging. Here is where you set your project to a development or shipping build and set options such as whether or not to do a full rebuild each time you run one. You can also set the Blueprint nativization method if desired, which converts them to C++ during the build process and will be discussed more in Chapter 8, Optimization, Testing, and Packaging.
After that comes Supported Hardware, which is self-explanatory, and then Target Hardware. When we were first setting up our project, we set it to Desktop / Console and Maximum Quality. If you needed to change it, here is where that is done.
One last section you'll want to explore on your own is the Engine section. A lot of the defaults are set here for things such as AI movement, animation compression, and audio classes.
Further down in the Engine section are the physics defaults, where you can set things such as gravity (which, as discussed, can be overridden per level), terminal velocity, and friction settings.
The last part of the engine settings I want to talk about is rendering. Here is where the major components of the graphics will be adjusted, such as ambient occlusion and motion blur. Depending on the scope of your project, some of these will not be needed, and they can be individually disabled here to increase your game's performance and fit your game's art style.
The input settings are part of the Engine section, but I want to discuss it separately from the other editor preferences. This section defines the keyboard, mouse, and gamepad inputs that our game will use, and will come into play in Chapter 2, Programming Using Blueprints. Let's take a look at the inputs that have been provided for our third-person project:
When you create your project, these inputs will automatically be created based on the template you use, but you will naturally want to add more depending on your gameplay. For instance, to add a Use key, you would press the plus sign next to Action Mappings, then change the name from NewActionMapping_0 to Use, and then select a keyboard key for it to use (E is common). Now, when you are creating or modifying your character class, you will be able to use this as an input event (discussed more in Chapter 2, Programming Using Blueprints).
Axis Mappings have an additional setting for scale, since they include gamepad thumbsticks that don't have a strict on/off state. If you look at MoveForward for example, you can see that the backward key (S) also calls the same input event; it just gives it a negative value so the character will move in the opposite direction.
Now that we've customized the editor with our preferences, let's look at how to further expand the engine's capabilities by using plugins.
Plugins are packages of code that extend the functionality of the editor in a variety of ways. They can be used for importing file formats the UE is unfamiliar with by default, and add entirely new functionality, such as analytics.
Plugins can be found by going to Edit | Plugins. Once open, we can see a list of available plugins divided into categories:
A lot of plugins are built into the engine and can be enabled or disabled as needed. Speaking of which, if you have Steam VR installed, you may have noticed that it started up automatically when the project launched. Since we're not going to be using any VR functionality in this book, let's disable that plugin now so Steam VR doesn't load every time we start up the editor:
- To disable it, go to the Plugins browser.
- Scroll all the way down on the left side and click on the Virtual Reality category.
- On the right side, scroll down to Steam VR and uncheck it.
- The editor will let you know that you need to restart for the setting to take effect, so click on the Restart Now button to do that.
- Steam VR will not close on its own once you've done this though, so you will need to close that separately.
Plugins can also be downloaded and installed from third parties. One of the most useful ones, if you're making a multiplayer game, is the Advanced Sessions plugin by Joshua Statzer. This can be used to make it easier to set up multiplayer server browsers on Steam, for example. Download links can be found on the Epic forums by searching for UE4 Advanced Sessions. Once downloaded, you would need to create a Plugins folder in your project as follows:
After creating the folder, you would place the Plugins folder inside (make sure the editor is shut down), and then start the editor back up, to have the plugin loaded. Most external plugins will provide documentation or example maps that have the relevant Blueprint classes and explanations on how to use them.
The final thing I want to discuss in this chapter is using marketplace items. The marketplace includes a lot of great assets you can use to speed up your prototype and development process. Why reinvent the wheel if you can save time and money? In addition to 3D models and materials, the marketplace is a good place to find Blueprint assets that give you a launching point for functionality in your game by providing things such as inventory systems or role playing game stat elements.
For this project, we will be downloading and installing one of the free packs provided by Epic, the Animation Starter Pack. It has weapon-oriented animations that we will be using in Chapter 5, Animation Blueprints, as we get into that topic. Let's follow these steps to download the pack:
- Head back to the Epic Games launcher and search the marketplace for the Animation Starter Pack:
- Add it to your cart and go through the checkout process, and the pack will appear in your Library tab in the Vault section underneath the My Projects section:
- Click Add To Project, then select our AwesomeGame project. Once it's finished, you'll be able to see the folder in the Content Browser:
And that's it! Take a minute to browse the marketplace, since Epic has provided a lot of free content to start with, and some of the other content available there will save you a lot of development time and headaches.
In this chapter, we've downloaded and installed the Unreal Engine, and we've taken a look at the templates we can use to get a headstart on our project's development. We've broken down the editor panel by panel to get familiar with how everything is organized, and customized it using the editor preferences. Finally, we've seen how to use plugins and marketplace items to expand on the editor's capabilities and further simplify our own project's development.
As with any complex piece of software, the UE has a lot of systems that you will need to be familiar with in order to make full use of it. In the upcoming chapters, we will be going through most of the major ones, so you will be able to get a well-rounded crash course and know where to go to find any additional information you need.
First, we will be discussing Blueprints, a great alternative to traditional programming. It is easily possible to create entire games using Blueprints alone, without ever having to touch a line of code.
Having said that, we will also have a quick lesson on adding C++ to a Blueprint project to extend our Blueprint functionality.
We will also cover other major systems, such as using UMG to create menus and HUDs, animation Blueprints to control our character, and using replication to create multiplayer games.
Finally, we will talk about the final steps of a project, covering optimization, testing, and deployment.
Let's get started!