Welcome to the amazing world of game development with Unreal Engine 5. In this book, we will learn how to develop games in Unreal Engine using the Blueprints Visual Scripting language, which was created by Epic Games for Unreal Engine.
The first step that is needed before we can learn about Blueprints is to prepare our development environment. Unreal Engine is free to download. We will learn how to install Unreal Engine 5 and create a new project. After that, we will learn about some of the basic concepts of Blueprints and explore each panel of the Blueprint Editor.
In this chapter, we will cover the following topics:
- Installing Unreal Engine
- Creating new projects and using templates
- Blueprints Visual Scripting
- The Blueprint Class Editor interface
- Adding Components to a Blueprint
Installing Unreal Engine
- Access the website at https://www.unrealengine.com.
- Register and download the Epic Games Launcher.
- Install and start the launcher.
- Click the Unreal Engine tab on the left-hand side.
- Click on the Library tab that appears at the top of the screen.
- Click the + button next to ENGINE VERSIONS to add a version of Unreal Engine to the launcher. You can use the newest version available.
- Click the Install button. The launcher will start downloading the files needed for installation and may take a long time to complete.
- Click the Launch button to start an already installed version. It is possible to have multiple versions of Unreal Engine installed on the same machine – you simply set one of them as the current version. The Launch button at the top right of the launcher will start the current version.
The Blueprint Visual Scripting system is already a well established and stable technology. This book uses version 5.0.0, but the examples created in this book should work without problems in later versions.
Creating new projects and using templates
After starting up Unreal Engine Editor, the Unreal Project Browser will appear. The Recent Projects box on the top left is used to open existing projects and the other boxes on the left are categories of templates used to create a new project. The following screenshot shows the templates of the Games category.
Templates are basic containers with some key files and a level that provide a basic starting point for different types of projects. They are useful for rapid prototyping or to learn the basic mechanics of a specific type of project. The use of templates is optional. All templates can be simply recreated in the blank template. The following are descriptions of each template in the Games category:
- First Person: For games with a first-person perspective. This template features a player character represented by a pair of arms equipped with a gun that fires a simple sphere projectile. The character can be moved around the level using a keyboard, controller, or virtual joystick on a touch device.
- Handheld AR: For augmented reality applications for Android and iOS devices. This template features runtime logic for toggling AR mode on and off, along with some example code for hit detection and light estimation handling.
- Third Person: Contains a playable character with a camera that follows it. The camera is positioned behind and slightly above the character. The character has walking, running, and jumping animations and can be moved around the level using a keyboard, controller, or virtual joystick on a touch device.
- Top Down: Contains a character controlled by a mouse with a camera at a great distance above it. The player's character is controlled using a mouse or touchscreen to click on the required destination and uses the navigation system to avoid obstacles when moving to destinations. This top-down view is often used in action role-playing games.
- Virtual Reality: Contains the essential features for virtual reality games. This template features teleport locomotion, grabbable objects, interactive objects, and a VR spectator camera. The template has a level where the player can move around and contains objects that can be grabbed and interacted with.
- Vehicle: Contains a regular vehicle and a complex vehicle with suspension. The level of this template contains a simple track and obstacles.
At the bottom right of the Unreal Project Browser, there are the Project Defaults with project configuration options available for the selected template. In the examples of this book, we will use the values selected on the screenshot. These options can be modified later in the project, and they are as follows:
- Blueprint/C++: There are templates made with Blueprint or the C++ programming language. In this book, we will only use Blueprint templates. A project in Unreal Engine 5 can be developed using Blueprint, C++, or a combination of both. You can add C++ code to Blueprint projects and Blueprint to C++ projects.
- Target Platform: Desktop or Mobile. Use Desktop if you are developing your project for use on computers or game consoles. Choose Mobile if your project will be viewed on a mobile device. In this book, we will use the Desktop option.
- Quality Preset: Scalable or Maximum. These options affect the project's performance. The Scalable option disables some complex features, and the Maximum option enables all the features available in the target platform. In this book, we will use the Scalable option.
- Starter Content: If this checkbox is marked, the project will include Starter Content. Starter Content is a content pack with simple meshes, materials, and particle effects. The examples in this book assume that Starter Content is being used.
- Raytracing: If this checkbox is marked, the project will use real-time raytracing, which is a performance-intensive feature. The examples in this book will not use raytracing.
Select the Third Person template, choose a location folder, and fill in the Name field for the project. Select the Project Defaults mentioned in the previous list and then click the Create button. After the project loads, the Unreal Engine Level Editor will be displayed, as shown in the following screenshot:
These are the key panels of the Level Editor:
- Toolbar: Located at the top of the Level Editor. It contains buttons with commonly used operations. The toolbar buttons are separated into four groups. The first group from the left provides quick access to features such as saving your work and adding various objects and code to the project. The second group of buttons are used to change the editing mode of the Level Editor. The third group lets you play the current level and provides various platform-specific options. The final Settings button all the way on the right provides easy access to project settings.
- Viewport: Located at the center of the Level Editor. It shows the Level that is being created. You can use the Viewport panel to move around the Level and add objects on the Level. When holding down the right mouse button, move the mouse to rotate the camera and use the WASD keys to move around.
- Content Browser: This can be accessed by clicking on the Content Drawer button located at the bottom-left corner of the Level Editor. It is used to manage the assets of the project. An asset is a piece of content in an Unreal Engine project. For example, Materials, Static Meshes, and Blueprints are all assets. If you drag an asset from the Content Browser and drop it into the Level, the Editor creates a copy of the asset to place in the Level.
- Outliner: Located to the right of the Level Editor. It lists the objects that are in the Level.
- Details: Located to the right of the Level Editor, below Outliner. It shows the editable properties of an object that is selected in the Viewport.
Now that we have an overview of the Unreal Engine Level Editor, let's focus on the Blueprints Visual Scripting.
Blueprints Visual Scripting
The first question you should be asking is: what is a Blueprint?
The word Blueprint has more than one meaning in Unreal Engine. First, it is the name of a visual scripting language created by Epic Games for Unreal Engine. Second, it can refer to a new type of game object created using the Blueprint language.
There are two main types of Blueprints: Level Blueprint and Blueprint Class. Each Level of the game has its own Level Blueprint and it is not possible to create a separate Level Blueprint. On the other hand, Blueprint Class is used to create interactive objects for the game and can be reused in any Level.
Opening the Level Blueprint Editor
To open the Level Blueprint Editor, click on the Blueprints button located in the leftmost group of buttons in the toolbar of the Unreal Editor. Then, select the Open Level Blueprint option from the dropdown, as shown in the following screenshot:
The Editor will open the Level Blueprint of the current Level. The Level Blueprint Editor is simpler than the Blueprint Class Editor because it has only the My Blueprint panel, the Details panel, and the Event Graph Editor. The following screenshot shows the Level Blueprint Editor:
For now, we will not do anything with the Level Blueprint. We opened it to get our first glance at the interface. Close the Level Blueprint Editor to return to the Level Editor window. Now, we will create a Blueprint Class to open the Blueprint Class Editor and see all the panels available.
Creating a Blueprint Class
There are three ways to create a Blueprint Class:
- Click the same Blueprints button in the toolbar that we used to open the Level Blueprint. Then, click the New Empty Blueprint Class button in the dropdown.
- Click the Content Drawer button to open the Content Browser, then click the Add button and select Blueprint Class under the Create Basic Asset category.
- Right-click anywhere on an empty space in the Content Browser and select Blueprint Class from the menu that appears.
On the next window, you must choose the parent class of the new Blueprint. For now, think of the parent class as the Blueprint type. The window shows the most Common classes, but if you need to choose another parent class, then just expand the All Classes option. When you choose the parent class, this window will close, and a new Blueprint asset will appear in the Content Browser to be renamed. You can click the Cancel button because we are just familiarizing ourselves with the process.
Now that we've learned how to open the current Level Blueprint and how to create a Blueprint Class, we will explore the panels of the Blueprint Class Editor. You can open the Blueprint Class Editor by right-clicking on a Blueprint asset in the Content Browser and selecting Edit, or by double-clicking on a Blueprint asset.
The Blueprint Class Editor interface
The Blueprint Class Editor contains several panels. Each panel is used to edit one aspect of a Blueprint. The Blueprint Class Editor is usually simply called the Blueprint Editor. The main panels of the Blueprint Editor are listed as follows:
- My Blueprint
- Event Graph
These panels can be found in the next screenshot. We will use the BP_ThirdPersonCharacter Blueprint of the Third Person template as an example. It is located in the
ThirdPerson/Blueprints folder. Double-click the BP_ThirdPersonCharacter Blueprint to open the Blueprint Class Editor.
The Toolbar panel
The buttons are described as follows:
- Compile: Converts the Blueprint script into a lower-level format that can be executed. That means a Blueprint must be compiled before running the game or the changes made will not be reflected. Click this button to compile the current Blueprint. A green check icon will appear if there is no error.
- Save: Saves all changes made to the current Blueprint.
- Browse: Shows the current Blueprint Class in the Content Browser.
- Find: Searches within a Blueprint.
- Hide Unrelated: When active, it hides the nodes unrelated to the selected nodes.
- Class Settings: Allows editing of the settings for the class in the Details panel. The Class Settings options contain properties such as Description, Category, and Parent Class.
- Class Defaults: Allows editing of the Class Defaults in the Details panel. Class Defaults are the initial values of the Blueprint variables.
- Simulation: Allows the execution of the Blueprint inside the Blueprint Editor.
- Play: Allows you to play the current Level.
- Debug Object: This dropdown allows the selection of an object to debug. If none is selected, it will debug any object created with the current Blueprint Class.
The Components panel
Components are ready-to-use objects that can be added to Blueprints. To do this, click on the Add button of the Components panel. A Blueprint can be created with various features just by using Components.
Static Meshes, lights, sounds, box collisions, particle systems, and cameras are examples of Components found in the Components panel.
The My Blueprint panel
New elements can be added by clicking on the Add button at the top of the panel, or the + button next to each category.
The Details panel
The Details panel allows you to edit the properties of a selected element of a Blueprint. The selected element can be a Component, Variable, Macro, or Function element. The properties shown in the Details panel are organized into categories.
The next screenshot shows the properties of a CapsuleComponent. There is a Search box at the top of the panel that can be used to filter the properties.
The Viewport panel
The Viewport panel shows the visual representation of a Blueprint and its Components. The Viewport panel has controls similar to the Level Editor, which you can use to manipulate the location, rotation, and scale of the Components.
The following screenshot shows the Viewport panel. There is a SkeletalMesh Component that represents the player, a Camera Component that defines the view of the player, and a Capsule Component used for collision detection.
The Event Graph panel
It is in the Event Graph panel that we are going to program the behavior of a Blueprint. The Event Graph contains Events and Actions that are represented by nodes and connected by wires.
An Event is represented by a red node and is triggered by gameplay Events. A Blueprint can have several Actions that will be performed in response to an Event. The next screenshot shows two Events: InputAxis TurnRate and InputAxis LookUpRate:
You can move around the Event Graph by right-clicking and dragging it to see the other Events.
The other nodes are Actions representing functions, operators, and variables. We will learn about these elements in Chapter 2, Programming with Blueprints.
Adding Components to a Blueprint
- Click the Content Drawer button to open the Content Browser, then click the Add button and select Blueprint Class.
- On the next screen, choose Actor as the parent class.
- Rename the Blueprint we just created to
BP_RotatingChair. Blueprints cannot have spaces in their name and there is a convention of starting Blueprint names with
- Double-click this Blueprint to open the Blueprint Editor.
- On the Components panel, click the Add button and select Static Mesh, as shown in the following screenshot. This Static Mesh will visually represent this Blueprint.
- On the Details panel, there is a property named Static Mesh, which has a drop-down input. Click on the dropdown and select the Static Mesh property named SM_Chair. This Static Mesh is part of the starter content. The following screenshot shows the selected SM_Chair:
- Let's add another Component. Click the Add button of the Components panel and type
rotating movementin the Search box.
- Click on the Rotating Movement Component to add it. By default, this Component will rotate the Blueprint around the z axis, so we don't need to change its properties.
- Click the Compile button and save the Blueprint.
- On the Level Editor, drag the BP_RotatingChair Blueprint from the Content Browser and drop it somewhere in the Level.
- Press the Play button of the Level Editor to see the rotating chair. You can use the WASD keys to move the character and the mouse to rotate the camera. You can exit the Level being played by pressing the Esc key. The next screenshot shows the example in execution:
In this chapter, we learned how to install Unreal Engine and create new projects using the available templates. We learned that there are two main types of Blueprints: Level Blueprint and Blueprint Class.
Then, we explored the different types of panels that are part of the Blueprint Editor. Our familiarization with these panels will help when developing with Blueprints. Finally, we also created a simple Blueprint using only Components.
In the next chapter, we will learn how to program the behavior of Blueprints using Events and Actions.
- You can have multiple versions of Unreal Engine installed on your computer.
- The Level Blueprint Editor has more panels than the Blueprint Class editor.
- Which type of Blueprint is appropriate for creating objects that can be reused in any Level?
a. Level Blueprint
b. Blueprint Class
- Which panel in the Blueprint Editor is where Events and Actions can be added?
a. Components panel
b. Event Graph panel
c. My Blueprint panel
d. Details panel
- Which panel in the Blueprint Editor shows the variables and functions of the current Blueprint?
a. Details panel
b. Components panel
c. My Blueprint panel
d. Event Graph panel