In this article, we will discuss data types: nodes representing single pieces of information.
Data is the core of every script; in fact, all that computers do is manipulate and pass data.
There are many data types available for us to use in Unity Visual Scripting, but we don’t need to be familiar with all of them; The following are the most common ones:
We have two types for representing numbers:
Integer is a data type of number values like
-9, commonly used for counting or ordering.
It can represent both positive and negative numbers, but not numbers with a fraction like
To represent these numbers with a fraction, we have the Float data type like
-2.4; Primarily used for measuring. However, besides storing both positive and negative numbers, it’s not limited to fraction numbers only – it can also represent an integer-like value such as
We mentioned we use number types for counting or measuring. In addition, we can also use them for arithmetic operations like addition and division or even comparing whether, for example, one number is greater than another.
Boolean is a data type with only two possible values – either
false. It can represent an object state, like whether a door is open or closed.
As we will later learn, we can leverage them to execute different sections of the Graph’s flow.
A String is a variable-length text, a sequence of characters like a name or a message. It can contain letters, numbers, symbols, and even emojis.
We can use it to print messages to the debug console or display dynamic text in the game’s UI.
Enum, short for Enumeration, is a data type consisting of a predefined set of values. For example, we can have a Platform enum made of
Xbox. We will usually use them to specify a single value from the available options it defines.
Vectors are a group of 2, 3, or 4, Float values. It can represent a character’s position, speed of a moving object, the distance between objects, and more.
Depending on the vector type, we can access its float components through the
For example, a Vector 3 consists of three floats accessed through
Nodes may have input and output ports; each excepts or provide a value of a specific data type. We can distinguish the port’s data type by its icon.
Besides nodes’ ports, we can add a data type value in our script using a Literal. In the Fuzzy Finder, we can search for the
Literal term of each data type to add it to the script and then pass it as an input to another node.