Blueprints Visual Scripting for Unreal Engine 5 - Third Edition

By Marcos Romero , Brenden Sewell
    What do you get with a Packt Subscription?

  • Instant access to this title and 7,500+ eBooks & Videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Chapter 1: Exploring the Blueprint Editor

About this book

Unreal Engine's Blueprint visual scripting system enables designers to script their games and programmers to create base elements that can be extended by designers. With this book, you'll explore all the features of the Blueprint Editor, along with expert tips, shortcuts, and best practices.

The book guides you through using variables, macros, and functions, and helps you learn about object-oriented programming (OOP). You'll discover the Gameplay Framework and advance to learning how Blueprint Communication allows one Blueprint to access information from another Blueprint. Later chapters focus on building a fully functional game step by step. You'll start with a basic first-person shooter (FPS) template, and each chapter will build on the prototype to create an increasingly complex and robust game experience. You'll then progress from creating basic shooting mechanics to more complex systems such as user interface elements and intelligent enemy behavior. The book demonstrates how to use arrays, maps, enums, and vector operations and introduces the elements needed for VR game development. In the final chapters, you’ll learn how to implement procedural generation and create a product configurator.

By the end of this book, you'll have learned how to build a fully functional game and have the skills required to develop an entertaining experience for your audience.

Publication date:
May 2022
Publisher
Packt
Pages
568
ISBN
9781801811583

 

Chapter 1: Exploring the Blueprint Editor

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

To use Unreal Engine, you must first install the Epic Games Launcher:

  1. Access the website at https://www.unrealengine.com.
  2. Register and download the Epic Games Launcher.
  3. Install and start the launcher.
  4. Click the Unreal Engine tab on the left-hand side.
  5. Click on the Library tab that appears at the top of the screen.
  6. Click the + button next to ENGINE VERSIONS to add a version of Unreal Engine to the launcher. You can use the newest version available.
  7. Click the Install button. The launcher will start downloading the files needed for installation and may take a long time to complete.
  8. 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.
Figure 1.1 – Launching Unreal Engine

Figure 1.1 – Launching Unreal Engine

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.

Figure 1.2 – Templates under the Games category

Figure 1.2 – Templates under 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:

Figure 1.3 – The Unreal Engine Level Editor

Figure 1.3 – The Unreal Engine Level Editor

These are the key panels of the Level Editor:

  1. 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.
  2. 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.
  3. 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.
  4. Outliner: Located to the right of the Level Editor. It lists the objects that are in the Level.
  5. 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:

Figure 1.4 – Opening a Level Blueprint

Figure 1.4 – Opening a Level Blueprint

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:

Figure 1.5 – The Level Blueprint Editor

Figure 1.5 – 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:

  1. 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.
  2. 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.
  3. Right-click anywhere on an empty space in the Content Browser and select Blueprint Class from the menu that appears.
Figure 1.6 – Creating a Blueprint Class

Figure 1.6 – Creating a Blueprint Class

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.

Figure 1.7 – Blueprint Parent Class

Figure 1.7 – Blueprint Parent Class

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:

  1. Toolbar
  2. Components
  3. My Blueprint
  4. Details
  5. Viewport
  6. 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.

Figure 1.8 – Blueprint Editor panels

Figure 1.8 – Blueprint Editor panels

The Toolbar panel

The Toolbar panel is located at the top of the Blueprint Class Editor and contains some essential buttons for editing Blueprints:

Figure 1.9 – Toolbar panel

Figure 1.9 – 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

The Components panel shows all the Components that are part of the current Blueprint.

Figure 1.10 – Components panel

Figure 1.10 – 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.

The properties of a selected Component can be edited on the Details panel and the visual representation of some Components can be seen on the Viewport panel.

Static Meshes, lights, sounds, box collisions, particle systems, and cameras are examples of Components found in the Components panel.

The My Blueprint panel

My Blueprint is a panel where we can create Variables, Macros, Functions, and Graphs for the Blueprint:

Figure 1.11 – My Blueprint panel

Figure 1.11 – 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 properties of a selected element can be edited in the Details panel.

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.

Figure 1.12 – Details panel

Figure 1.12 – Details panel

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.

Figure 1.13 – Viewport panel

Figure 1.13 – Viewport panel

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:

Figure 1.14 – Event Graph panel

Figure 1.14 – Event Graph panel

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.

After this overview of the Blueprint Editor panels, we are now able to create our first Blueprint. Close the Blueprint Class Editor and navigate back to the Level Editor.

 

Adding Components to a Blueprint

Now, let's create our first Blueprint. It will be a very simple Blueprint that will only contain Components. For now, we will not use Events or Actions:

  1. Click the Content Drawer button to open the Content Browser, then click the Add button and select Blueprint Class.
  2. On the next screen, choose Actor as the parent class.
  3. 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 BP_.
  4. Double-click this Blueprint to open the Blueprint Editor.
  5. 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.
Figure 1.15 – Adding a Static Mesh Component

Figure 1.15 – Adding a Static Mesh Component

  1. 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:
Figure 1.16 – Selecting a Static Mesh asset

Figure 1.16 – Selecting a Static Mesh asset

  1. Let's add another Component. Click the Add button of the Components panel and type rotating movement in the Search box.
  2. 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.
  3. Click the Compile button and save the Blueprint.
  4. On the Level Editor, drag the BP_RotatingChair Blueprint from the Content Browser and drop it somewhere in the Level.
  5. 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:
Figure 1.17 – The rotating chair

Figure 1.17 – The rotating chair

 

Summary

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.

 

Quiz

  1. You can have multiple versions of Unreal Engine installed on your computer.

a. True

b. False

  1. The Level Blueprint Editor has more panels than the Blueprint Class editor.

a. True

b. False

  1. Which type of Blueprint is appropriate for creating objects that can be reused in any Level?

a. Level Blueprint

b. Blueprint Class

  1. 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

  1. 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

About the Authors

  • Marcos Romero

    Marcos Romero is the author of the Romero Blueprints blog, which is one of the main references on the internet to learn about Blueprints. Epic Games invited Marcos to the Unreal Engine 4 closed beta program to experiment and collaborate with the evolution of the tools. He was also one of the first recipients of Unreal Dev Grants for Education. Marcos is a well-known figure in the Unreal community and, for Epic Games, he wrote the official Blueprints Compendium and Blueprints Instructor's Guide.

    Browse publications by this author
  • Brenden Sewell

    Brenden Sewell is a game designer and creative director with over a decade of experience leading teams in the development of compelling interactive experiences that entertain and inspire. Prior to joining Bossfight Entertainment to work on some upcoming secret projects, he explored the intersection of social impact and entertainment serving as the Creative Director for E-line Media. He has led developments from concept to live support on a variety of games ranging from a brain-training first-person shooter to a construction sandbox exploring the future of digital fabrication.

    Browse publications by this author
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition
Unlock this book and the full library FREE for 7 days
Start now