Book Image

Unreal Engine Game Development Blueprints

By : Nicola Valcasara
Book Image

Unreal Engine Game Development Blueprints

By: Nicola Valcasara

Overview of this book

With the arrival of Unreal Engine 4, a new wonderful tool was born: Blueprint. This visual scripting tool allows even non-programmers to develop the logic for their games, allowing almost anyone to create entire games without the need to write a single line of code. The range of features you can access with Blueprint script is pretty extensive, making it one of the foremost choices for many game developers. Unreal Engine Game Development Blueprints helps you unleash the real power of Unreal by helping you to create engaging and spectacular games. It will explain all the aspects of developing a game, focusing on visual scripting, and giving you all the information you need to create your own games. We start with an introductory chapter to help you move fluidly inside the Blueprint user interface, recognize its different components, and understand any already written Blueprint script. Following this, you will learn how to modify generated Blueprint classes to produce a single player tic-tac-toe game and personalize it. Next, you will learn how to create simple user interfaces, and how to extend Blueprints through code. This will help you make an informed decision between choosing Blueprint or code. You will then see the real power of Unreal unleashed as you create a beautiful scene with moving, AI controlled objects, particles, and lights. Then, you will learn how to create AI using a behavior tree and a global level Blueprint, how to modify the camera, and how to shoot custom bullets. Finally, you will create a complex game using Blueprintable components complete with a menu, power-up, dangerous objects, and different weapons.
Table of Contents (14 chapters)

Visual Studio


You learned how to use the Unreal Engine 4 (UE4) editor and the basics of Blueprints. Now is time to go through the core of the engine. Code! Let's take a look at Visual Studio and get ready to comprehend lines of code together while we create our Blueprint scripts. In the examples provided in this book, you will often see different approaches to the same simulation. The goal of this guide is to teach you to not only be able to decide when Blueprint is useful, but also be able to write some lines of code.

Creating the project solution

We created our project as a Blueprint empty project, now we need to create our Visual Studio solution for it. Open your project folder through Explorer. You should have a situation similar to the following screenshot:

Unreal Engine provides you a C++ wizard that helps you in this process. Locate .uproject (usually the name of your project.uproject). Right-click on Generate Visual Studio project files. The UnrealBuildTool file should start and you should see your folder slightly changed at the end of the process, as follows:

If this solution doesn't work, you can generate the project solution directly from the editor. Under the menu bar, navigate to File | Generate Visual Studio Project. If it still doesn't work, remember that the engine will generate a project solution as soon as you add a C++ class to the project in case there isn't any Visual Studio project.

Let's have a brief look at these folders, as shown in the following:

  • Binaries: It contains executable or other files that are created during compiling.

  • Config: Configuration files are used to set values that control engine and game default behavior.

  • Content: It holds all the content of the game, including asset packages and maps.

  • Intermediate: It contains temporary files that are generated during the building of the engine or game.

  • Saved: It contains autosaves, configuration (same *.ini of Config folder) files, and log files. Here, you can find crash logs, hardware information, and swarm options and data.

  • Source: It contains all the source files for the game divided in to object class definitions (.h files) and object class implementation (.cpp files).

Now, we can open the project solution by double-clicking the .sln file or under File | Open Visual Studio Project through the editor:

One of the problem of UE3 was that whenever you wrote or modified your unrealScripts to test and see your modifications in the engine, you were obligated to restart the editor, losing a certain amount of time due to closing and opening it a hundred times during the development.

On UE4, this is not needed anymore. You can compile your script directly within the editor, and each modification you make on both side (Code or Engine) is automatically updated.

Add a new class from the editor

To add a new class from the editor, we can navigate to File | New C++ Class… from the menu bar. A pop-up window similar to the Blueprint one will appear where the editor will ask you to choose the parent class.

Note

Notice that here you can choose to not have a parent for your class, which is different from the Blueprint class, where it needed to have a parent class.

When you choose a parent, you need to specify a name for it and its path (keep all your code under the Source folder). The C++ wizard will add a header and a C++ file for you and, when finished, will ask you whether you want to immediately edit that file:

For any other parent class that you choose, except none, the wizard will add the most used functions for you on the new class together with the constructor. By default, you will find your class ready to be implemented with the BeginPlay function and the Tick functions:

Now that you know how to create your classes, you are ready to write your own code. We will see what to write and how to debug from Visual Studio in detail in the next chapters.