Variable Types in UE4

In the engine there are built in types of variables and the possibility to create our own.

In this lesson, we will take a look at the basic types :]

Name Color in Blueprints Example Values and Uses

Boolean (bool)

Red RedWire.png

True or False.

Is someone alive? Is anything in the air now? Is a door locked?

Integer
(int)

Turquoise CyanWire.png

Whole numbers

1,2,3..
0
-1,-2,-3…

e.g. the number of bullets in the magazine (can’t be a fraction like 1.5)

Float Green

Any number, including whole numbers and non-integer numbers

-1,0,1,2,3…

0.1, 3.14, 99.9,…

e.g. a weight of something can be 1, 1.3 etc.

Note that although a weight can’t be negative, to support fractions, it is defined as a float. It’s our responsibility as developers to guarantee that it doesn’t get a negative value.

In fact, many times, float is used to hold a number between 0 and 1 (0.2, 0.5, 0.99…), and these are actually percentage (20%, 50%, 99%).

String Purple MagentaWire.pngA Any text. Words, sentences, messages etc.
Text Pink PinkWire.png A little tricky, because it’s very similar to the previous one (string), but it’s still used here and there, for example, names of labels. The use is quite identical to the use of string.
Vector Yellow GoldWire.png

A combination of 3 floats in one value, where each has its internal name X/Y/Z.

For example, the combinations (1,0,0)   (5,5,5)   (-2.33,  5.7,  0), in which, by order,
X  = 1, 5, 0
Y = 0, 5, 5.7
Z = 0, 5, -2.33

Vectors are often used for locations of objects, where
X = Forward
Y = Right
Z = Up
Negative value is the reverse. For example, -5 forward is actually 5 backward.
Rotator Bluish-Purple PurpleWire.png

Just like a Vector, a Rotator is also comprised of 3 floats, except that this time they are degrees (of an angle)

360 is identical to 0, 180 is identical to -180, 90 is identical to -270 etc.

The rotator defines the direction objects turn to. For example, when we move the mouse in a shooting game, we add a Rotator to the camera.

In a Rotator, the numbers are defined by the names pitch, yaw, roll, each is for a rotation around a certain axis.

pitch = rotation around the Y axis, like landing a takeoff of an airplane, or mouse up-down in a shooting game.
yaw = rotation around Z, like a mouse moving right and left in a shooting game, or a car turning to the side.
roll = rotation around the X axis. For example, Headstand is a 180 degrees roll.

Transform Orange OrangeWire.png

Just as a Vector is a combination of floats, Transform is a combination of scale, rotation, location, where:
location – vector
rotation – rotator
scale – vector (like location)

Very often this triplet is used to define the state of an object in the world. That’s why it was given its own name and type.

This way, instead of asking 3 question: “where are you?”, “what direction are you looking to?” and “what’s your size?”, we simply ask “what’s your Transform, Bro?”

In one word – convenient.

Object Blue BlueWire.png Object is its own topic, which we will learn in another lesson, but in short – everything which is not the other types.
In a nutshell, a cat is an Object, a table is an Object, a sound is an Object, mesh is an Object, a player’s gun is an Object of an Object etc.

In the next lesson we will learn more about objects and see that it is both a type and not a type. Our heads will explode with confusion, but that’s okay, because we will save the game before that 😉