1. Variables and DataTypes | UE 5 Blueprints

Aditya BurgulaAditya Burgula
4 min read

Accompanying Youtube Video Tutorial

Playlist Link -> %[https://youtube.com/playlist?list=PLgaxXvvBxTyHii9WD1WL8TjMUOtX4iIF-]

1. Introduction

Variables are extensively used in any software development. They allow us to do multiple operations on data like storing, editing, etc. In this tutorial, we will look at Datatypes and Variables in Unreal Engine Blueprints and work with them.

2. Concept

First, let us understand the concept of variables and data types.

The idea is very simple- they allow us to store data and manipulate data. For Example, you can consider an empty cardboard box as a Variable; whatever we put inside that box is data.

If we put balls in the box, we say it is a box of balls. If we put pencils in the box, we say it is a box of pencils.

In the same manner, if we put numbers inside a variable we say that the variable is a type of number.

3. Basic Datatypes

Let us discuss some basic data types below

  • Integer
  • Float
  • Boolean
  • Strings
  • Name
  • Text

3.1 Integer

In Unreal Engine Blueprints, three data types are used to store whole numbers and integers they are-

  1. Byte
  2. Integer
  3. Integer64

These 3 datatypes are used to store the same type of data i.e, Integers, but they are slightly different because they have different ranges of values they can store.

DatatypeRange
Byte0 to 255
Integer−2,147,483,648 to 2,147,483,647
Integer64−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Using this data type you can do various mathematical operations like Addition, Multiplication, Squaring, etc.

Example Usage - Integer datatype can used be to store the number of coins a player has collected, the number of players joined in a multiplayer, etc.

3.2 Float

Float is a datatype in blueprints that allows you to store fraction or decimal values. Example - 3.14159f, 22/7, 1/100, etc. Float also allow you to do numerical operation on them like Integer Datatype

Example Usage - This float datatype can be used to store the percentage of health; to record transform of an object like Position, Rotation, Scale; etc.

3.3 Boolean

Boolean data type allows you to store either True or False. These 2 values can also be represented using numbers 0 and 1 respectively.

Example Usage - Boolean datatype can be used to store player status like dead or alive. Apart from just dead and alive status, we can have more status if we use enums(we will cover in a later part of the series).

3.4 String

String datatype allows you to store any text, it can be a number, name, place, message, special symbols, etc. You cannot do any numerical operations on this datatype like Integer and Float if you decide to store numeric values in a string datatype. You can still do String operations(we will cover in a later part of the series) like replace, splice, etc.

Example Usage - You can use it to store names of players, chat messages within the game, print a debug message to the screen, etc.

3.5 Name

Name datatype is also similar to string but is mainly used to refer to names of assets or game objects inside your game like 3D Models, Levels or Maps, etc. This is an immutable data type which means can value stored inside a variable of Name datatype cannot be modified or changed.

Example Usage - Opening a level using “Load Level” Node, places where the text value of the variable doesn’t change.

3.6 Text

The text data type is similar to the string datatype. It is used mainly in UI(User Interface) or HUD(Heads Up Display) where text localization is necessary. Text Localization in simple words means making your application/game multilingual so that everyone can use or play it. The Text datatype makes localization very easy within the game.

4. Creating Variables

Follow the below steps to create a variable -

  1. In the Blueprint Graph, go to “My Blueprint” tab.
  2. In this tab, you can either click on the “Add” button or the “+” icon beside the text “Variable” to create a variable.
  3. Once you click any of the above-mentioned buttons, a new variable will be created and you will be prompted to enter the name of the variable and set the datatype.

5. Naming Convention

It is a common practice while using Unreal Engine Blueprints and Unreal C++ to follow Pascal Casing while naming variables. In PascalCasing you would capitalize every first letter of every consecutive word in the name.

For Example - “PlayerName”, “PointsToBeGainedByCollision”, etc.

In the case of naming Boolean variables, it is common practice to prefix the name with a small “b” and follow with PascalCasing. Don’t worry Unreal Engine will remove that small “b” in the graph node.

For Example - “bIsPlayerAlive”, “bIsPlayerOffline”, etc.

2
Subscribe to my newsletter

Read articles from Aditya Burgula directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aditya Burgula
Aditya Burgula