- Published on
Programming Fundamentals - Data Types and Variables
- Authors
- Name
- Hardly Brief Dan
- @HardlyBriefDan/
Programming Fundamentals Series
Welcome to the first part of the Programming Fundamentals Series with a focus on Game Development using Unreal Engine. This series uses examples from Unreal Engine and C++ but the content is useable in other engine and languages such as Unity, Godot, C# and more!
This post covers the basics of Data Types and Variables. It reviews what Data Types are, the various types you'll encounter in game development, and how to use them as Variables.
This post is part os a series and is similar to a section in my Free Unreal Engine Fundamentals Course.
Data Types and Variables
Data Types and Variables are foundational in programming and basic knowledge of them is required to be able to effectively build and create a game. We will review the what data types are, the most common data types used in game development, and what they look like in Blueprints.
What are Data Types?
They are a classification that specifies the type of data that will be used and defines the operations that can be performed on the data, the way the data is stored, and the possible values that the data can take.
What are the Common Data Types in Game Development?
There are a lot of different Data Types in programming and in Game Development and you can even create your own. But as you get started these are some of one the ones you will come across and use fairly quickly in your journey.
What are Variables?
Simply, a variable is a container for a specific data type (boolean, integer, string) and associated value that is given a symbolic or helpful name. Variables allow us to store, retrieve, and manipulate data within a program or game.
The above example, shows a variable named IsCourseHelpful
that is of Bool(or Boolean) Data Type. The name is helpful to the reader, as it clearly explains if the course is fun or is not fun based on its value of True
or False
.
Write bool values with prefixed verbs such as
Is
,Was
, orHas
. This helps identify the variable as boolean and understand its current state.
How can I create a Variable in Blueprints?
Creating a Variable in Unreal Engine's Blueprints is quick and simple! When you open a Blueprint, lets use the BPA_Tornado (any Blueprint file will work) from my Free Unreal Engine Course, you should see a window, similar to the below screenshot, called My Blueprint. There is a section labeled Variables. Here there should be a Plus icon that you can click and it will create a new Variable for you. You can edit the name and change the Data Type of the newly created variables.
You can also change the variable to a Collection which I will discuss in another post or you can learn today in the Free E-Book.
Variables in Blueprints
Below are some Variables using the common Data Types we discussed earlier in this post in Unreal Engine Blueprints. Each Variable shown has a Get
Blueprint node (the top nodes) and a Set
node (the bottom nodes).
If you hold
Ctrl
while you Click and Drag a Variable in a Blueprint graph aGet
node will be created. If you holdAlt
while you Click and Drag a Variable in a Blueprint graph aSet
node will be created.
Conclusion
When you first get started with programming and game development you can easily get overloaded with tons of information and learning opportunities. You can sometimes get stuck in analysis-paralysis where you are unsure on how to proceed or don't know the correct path forward and that it totally normal. Learn the basics, make a choice, learn from your mistakes, and keep building!