Inside of Unreal Engine Blueprint

blueprint

Blueprint is a great new feature in Unreal Engine 4, it is a visual scripting that enables everybody including non-programmers to easily creates and tweak Gameplay elements in the game, the tools to make and edit them in the editor are very rich and extendable.

As a game programmer, apart from using Blueprint as a mean to prototype a feature, we may want to extend and customize it to meet the requirements of the game we are working on, extending the blueprint comes in many different flavors, adding a custom blueprint elements in C++ is very easy, we only need to create various C++ functions and properties that are accessible from Blueprint, but sometimes it is not quite enough for us, sometimes we need to create a custom nodes that our game designer can easily use, create an automated process related to blueprint such as collecting blueprint classes, create a utility to convert our custom game actors or data into Blueprints, and many more, this is especially true if you are a tool programmer and trying to optimize the pipeline of your game.

To do an advanced customization of Blueprint, we need to know what is a Blueprint, what is really happening inside of it, what are the data, how does it generates its output, etc. This article is an overview of the answers to all of these questions. It is a part of my study that I want to share with you, in the hope that we can utilize Unreal Engine 4 to its full potentials in order to make a better game with it and especially to increase our productivity by making convenient and optimized tools that are related to Blueprint as part of our game production pipeline.

I will refer to this advance type of Blueprint customization simply as Blueprint customization. This article assume that you have already known Blueprint from end user perspective and also a bit of knowledge in CoreUObject, AssetRegistry, and UnrealEd modules.

What is a Blueprint?

In the simplest sense, Blueprint is just a black box that uses ParentClass as input and produces BlueprintGeneratedClass as output;  A very simple definition of Class would be a collection of information about properties and functions of an Object, and an Object itself is just a series of bytes, thus, a Class is some kind of map for us to know what a certain Object really is.

blueprint-blackbox

Blueprint itself is an asset, it is not a Class, this asset will not be cooked in the final package of our game, which means, we should never reference a Blueprint asset at run-time.

Blueprint is meant to be used in the editor, and making a Blueprint customization should only be done within the context of the editor, either by wrapping our customization codes in WITH_EDITOR or WITH_EDITORONLY_DATA or by creating an editor only module.

An example of blueprint customization is UWidgetBlueprint of UMG (Unreal Motion Graphics), it is derived from UBlueprint and has its own custom editor that is extended from the common blueprint editor, this custom editor has a designer panel that allows us to design the layout of the widget, it is very convenient compared to creating UI by code using Slate, especially for non programmers, it speeds up the UI development process significantly.

widget-blueprint

UWidgetBlueprint, no matter how different it is from ActorBlueprint or AnimationBlueprint, is basically doing the same thing, it creates a Class that extends its ParentClass to produce a new Class. The many extensions that has been done is just to empower UI programmers and designers in creating game user interface, in a sense, customizing a blueprint means we are creating a custom tool for our game production.

What are the Data?

We already know that the input of a Blueprint is a ParentClass, and the output is a BlueprintGeneratedClass. In producing the output, Blueprint processes a lot of Data inside of it, but before we are going inside a Blueprint you will need to redefine the term ‘Blueprint’ itself, from end-user perspective everything in a Blueprint is a Blueprint, the most common misconception is Blueprint Graph, most developers I know will say that a Blueprint Graph is a Blueprint, e.g: “Hey that’s a cool Blueprint, it looks so tidy, the lines are perfectly aligned and the comments are very descriptive, I like it.”, using the word Blueprint for Blueprint Graph will hinder your understanding of Blueprint. Blueprint is an Object that contains many data, including various Blueprint Graphs to produce a BlueprintGeneratedClass, that’s it!

So, What are the data? here they are:

Skeleton Object and Class Default Object

cdo

First of all Blueprint will generate a BlueprintGeneratedClass that is derived from the ParentClass, and then it creates two default objects for this generated class, one of them is a skeleton object (note: it has nothing to do with skeletal mesh), and the other one is the actual default object that will be use as the class default object of the generated class. If you edit an inherited property from the parent class in blueprint editor then you are actually editing the class default object, and if you revert the value that you have edited, then you are reverting it to its skeleton property value.

List of New Properties

vars

The second data in Blueprint is a list of new properties, when you add a new variable in Blueprint it will be added to this list. The mechanism of this property list is actually pretty complex that it needs its own article, so for this article we just assume that there is a property list that records new properties that we create in blueprint.

Simple Construction Script

scs

The third one is a Simple Construction Script (SCS), it is a tree that contains components to be instantiated when an object of this class is created, you can only see the tree when you are creating an actor blueprint, in the editor this is called components tree.

Blueprint Graphs

Graphs

The last one are various Blueprint Graphs, the correct technical term for this is Editor Graph (UEdGraph), there are four categories of Graphs in a common Blueprint: Event Graphs, Function Graphs, Macro Graphs and DelegateSignatureGraph (Event Dispatchers); If you have ever created a blueprint in the editor, then you should already know what they are just by looking at the categories on the left side of the graph editor. We can create more than one event graphs, but in the end they will all be collected into a single Graph that is called an UberGraph (you have probably heard of it when you have error in your blueprint graph). So, what are these graphs? they are basically source codes in the form of a graph that will be compiled into byte codes that can then be fed into UnrealScript virtual machine.

How Does It Generates Its Output?

To generate a BlueprintGeneratedClass, Blueprint needs to be compiled, the compilation process is done by FKismetCompilerContext that is created every time a blueprint is about to be compiled.

Epic has made a good documentation on how this compiler works, you can read it here:

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/TechnicalGuide/Compiler/

Summary

This is the end of this short article about what is inside an Unreal Engine Blueprint.

I hope this article can help you start your own journey in understanding and creating your own blueprint extensions that can help you optimize and speeds up your game production process and creating useful tools for your game development team.

Thanks for reading and please let me know if I have made mistakes in my article.

Published by

Fathurahman

I am a game programmer interested in many aspects of game programming especially tools development and User Interface. I am currently using Unreal Engine 5 for both work and off-work projects. I love to do figure drawing and digital painting in my free time.

3 thoughts on “Inside of Unreal Engine Blueprint”

    1. I’m learning them because I need to, the features of the game project that I did a couple of years ago was quite over the top that it required me to make a couple of changes to the early ue4 engine iteration (I believe it was UE4.6), and I learned more after that just to sate my curiosity, up until today in UE5.1.

      A lot of my friends in the local game Industry prefer Unity of Unreal Engine due to the rich documentation that the former provides, but for me, nothing beats reading and debugging the engine code myself, it’s always up to date and it is just so much fun tinkering with the engine.

      Unfortunately I have only managed to release two out of five UE game projects that I was in, Unreal Engine with its fancy next gen capability made financial backers and inexperienced decision makers (including game designer) making ‘unrealistic’ demands out of the engine, but that made me learn more just to prove that UE4 (at the time) was unable to meet their demands and that it would take months for us to wrote such feature ourselves.

      Like

Leave a comment