Realistic Basics Unreal Engine Blueprint Basics
GCC Academy
Hello
I am Tak Gwang-wook, and I will be teaching the Blueprint lecture
Blueprint is a system that you will cover a lot
when working with Unreal Engine
It refers to Unreal's unique design system
that designs and devises complex actors
This Blueprint can be added to operate
functions as well as appearances
In this session, we will focus on
the functions of Blueprint
First, we will take some time to become familiar
with the visual script of Blueprint
and learn about the basic knowledge
and theory for creating functions
Understanding Blueprints and Blueprint Scripting
Normally, the functions of a Blueprint Actor
are created through coding
Programmers create them using
coding syntax as if they were writing text
Unreal Engine provides a way for planners or artists
who are not familiar with coding to create Blueprint functions
using a method called visual scripting
so that they can implement functions very easily
As you can see in this picture
the visual scripting method is a method
of creating a function that works with a visual interface
that is, by connecting blocks
called modes with lines
to visually see the flow of data
In particular, the visual scripting method of Unreal Engine's Blueprint
provides more coding-related functions
than general Blue Coding
so it is very powerful to the point
that you can easily create a project of a certain scale
with only Blueprint without direct coding
First, let's learn how to use
Blueprints
When programmers learn to code
they usually start by creating a function
that prints Hello World
Let's create a function
that prints Hello World
I opened the basic level
Here, I'm going to learn about blueprints simply
Open the Content Drawer
and create a folder in the Content folder
I'm going to create a folder
called BP
It's short for Blueprint
We're going to learn inside this folder
Right-click on a space and select Blueprint Class
A window will pop up asking you to select a parent class
Simply put
when you create a blueprint in Unreal Engine
it says to take a specific function that's already been created
and add it to create a function
to create a blueprint
This method of making something by taking what was previously made
is usually called inheritance
So, you can think of it as a process of creating a new function
by inheriting a class
So you can think of it as choosing what to inherit
We will inherit the Actor class at the very top
This Actor class is
a class that has the function of
being placed in the level space
So, since we are going to place it in this level
we will select the Actor class
Then, the inheritance is received, and a blueprint is created
We'll call it BP_Basic
Then, a blueprint actor
that inherits the Actor class is created
Double-click
When you double-click
a blueprint editor window will appear like this
I aligned this editor window next to the level like this
To see the whole thing
If you look, there's an open space in the middle
and on the left are Components and My Blueprint
and on the right is the Details window
The Components on the left
are a panel where you can load function
blocks provided by Unreal
For example, My Blueprint is where
we will learn about variables later
And the Details on the right are familiar
You can think of it
as a panel for setting settings
The viewport is the same as a general viewport
You can think of it as a space to check the visual representation
and appearance of the blueprint
If you look at the work that we will be working on
if you click on the panel called Event Graph
next to the viewport at the top
you can see that the screen changes
You can create it here
There are three basic nodes
which I will explain later
If you right-click the blank space on the right
there's a search window
There's a list here, too
You can choose from here
but we'll search directly
Let's search for "print"
Then, we can pull out a node
called "Print String"
Let's click on it
Then, we pulled out a node called "Print String"
You can think of a Print String
as a block that prints out a specific phrase
So, it's in charge of printing out
the content inside
the square box in In String
Of course, we will do "Hello World,"
so we will write "Hello World" here
It doesn't end here
Now, where do we connect this node?
There's a red node called Event BeginPlay
It's the node that first appears
when we first create the blueprint
This node is called an event node
and you can think of it as a node that is told to run in a specific situation
In this case, it's BeginPlay
BeginPlay is a node
that generates an event
that runs when you first start playing
I think it would be good to think of it this way
Here, you can see a mark that looks like an arrow
This is called a run pin
If you click and drag this run pin to the side
a line will appear
If you connect this again
and connect it to the run pin in the Print String
the line will be connected like this
If the connection is incorrect and you want to cancel it
hold down the Alt key on your keyboard and click on the line to disconnect it
The line will disappear
Let's drag and drop the run pin again
and connect it to the Print String like this
Then, we're done
This node can be held like this and moved back and forth
You can also hold it and move it back and forth
Then, you can hold it like this and move it back and forth at the same time
You can zoom in and out using the mouse wheel button
If you zoom in, it will go up to here
and if you hold down the Ctrl key, you can zoom in even more
You can do it like this
Then, if you right-click and move the mouse back and forth
it's called pan movement
You can move the location like this
And then you're done
When you're done here
you need to click on the button
with the question mark that says Compile on the top left
Compile is
converting languages ​​people can understand
into languages ​​that a computer can understand
It's this kind of a proceed
So when we do these tasks
we need to click on this Compile button
And when we do a task
if you look at the top, you'll see
an * next to the name
And if you look at the assets
you can see that after doing some work
there is a * mark in the middle
What this * mark means is that
the work was done but not saved
It's like when we work on a Word
or PPT document
and write but don't save it
In the case of Blueprint, you can see that
it works stably only if
you save after Compile
So, I recommend you develop the habit of
always clicking the Compile
and Save button
So, I'll click the Compile button
And then, I'll click the Save button
Now, the * mark is gone
You can also see that the * mark is gone in the Content Drawer
We've created a simple Hello World function
so let's check if it works
The name Untitled hasn't been applied yet
Let's go back to the level
When we go back to the level, we need to open the Content Drawer
that we created and place this blueprint that we created
So we're going to do this by dragging and dropping
I have always habitually placed all assets
at the origin level
So, let's put it at the origin
and play it from this state
When you press the play button at the top
you can see Hello World briefly appear at the top of the viewport screen
and then disappear
It disappears too quickly, so let's fix it a little
If you press the arrow below this Print String
you can see the items that can set the Print String function
Here, the Duration is currently 2
This means it will be displayed for 2 seconds and then disappear
Let's increase this a little more
I'll set it so it will be displayed for 10 seconds and disappear
Since we've made our changes, let's compile
then compile at the top left
and then save it
Let's go back to the level
and press play again
How does it feel when you play it like this?
A blue text that says Hello World
is printed at the top left
You can also see it disappear after 10 seconds
Okay, that's it
We created the function using blueprints
Let's learn more about the nodes of
the blueprints we created
Here's a simple, frequently used node
This node is called Set Actor Rotation
and it's a node that sets the rotation of an actor
So, if you look at the top, you can see the name of this node
You can roughly tell what function this data has
from the name
And there's a white pin on top
I mentioned that this pin is an execution pin
When it receives a command to execute
this function operates through this node
When the operation is finished, through the execution pin behind it
the next task is executed
You can think of it as a pin that connects
the execution flow by receiving an execution command
and executing a command to execute
And there are pins like this at the bottom
All of these pins are called data pins
The one on the left is an input pin
So when executing a function in this node
the data to be input
is input through this pin on the left
The data completed and calculated through this node
is extracted through this pin on the right
So, the flow of this blueprint
is the flow of this data from left to right
As you can see
we start from the left and go to the right
This node, Event BeginPlay
is where an event occurs when it first starts
We connected it so that the following Print String
is executed when the event occurs
But in this Print String, we didn't receive any data
Even though there was a left pin, we didn't receive any data
but we input our data called Hello World
and made it run
In the case of this print
since the data will not fall through to the next node
there may not be an out pin
or an output pin that goes out
Instead, if you tell it to do something
next or another function
you can connect the execution pin like this
to do the next function
If you connect it like this, you can think of it as
doing a Print String
and then running Set Actor Rotation
Data Type and Blueprint Arithmetic Operations
Then, let's input some data into this pin
We're going to create a data called a variable and input it
A variable is
like a regular bowl
When we eat rice, we put rice in a bowl, right?
When we put soil
we put it in a bowl called a flower pot
We wouldn't put rice in a flower pot to eat
Right?
We process much data in programming
such as input ​​and output values
Each of those pieces of data
is stored in a bowl that can hold them
These bowls are called variables
Just like a typical container
variables cannot store all data
Whenever you create a variable
you determine the type of data it can store
and this purpose specification is called
a data type
So, how many data types are there?
There are two types of data types
basic data types that are determined in advance
when creating a programming language
and user-defined data types that are created to store classes
created by developers according to the development situation
Class data types and user-defined data types
are produced according to the developer's development situation
so there is no limit to the number
So, let's leave them out
Even if you only consider these basic data types
there are dozens
so it's impossible to memorize them all
So, let's practice creating a variable node
based on the four most
frequently used data types
In addition, we'll look at nodes
related to the functions we'll create this time
for frequently used nodes
Then, let's return and create
a variable in this Print String
and print the variable value
The way to create a variable is at the bottom left
There's a panel called My Blueprint at the bottom left
If you look at it, there's an item called VARIABLES
If you press the + button in VARIABLES
a variable is created like this
Here, let's create a name
Let's create Number1
I created a name
This is the name of the vessel
You can see what this vessel will be used
for by selecting the red Boolean item
on the right
When you click on it, several items will appear like this
All of these items are data types
There are quite a lot, right? We will only try four of them
Let's select the first one, Integer
Click on it, and it has changed to Integer
This setting means that vessel Number1
is a vessel that holds data called Integer
What is an Integer?
An Integer refers to a general integer
An Integer refers to an integer
If you select this variable and go to the Details window
you can configure various settings in the Details window
If you look at the bottom, there’s an item called Default Value
where you can specify a value
You can’t enter one right now It tells you to Compile
So, I’ll Compile it first
It tells you to Compile and then save it after Compile
After that, you can see
a variable named Number1
with the number 0 in it
We can enter any number we want here
Let’s try entering the number 100
Since it’s an Integer, a variable that holds an integer
the number 100 is entered
Let's try inserting a decimal point here
A decimal point is not an integer
If it were 100.1
the .1 at the end would be dropped
Since it's been modified again in this state, let's Compile, save
and connect this variable to Print String
Let's grab the variable and drag and drop it
into this blank space
When you drag and drop, two options will appear
Get Number1 will get this variable
Set Number1 will input a specific value into this variable
Since we're getting the value of this variable
let's select Get Number1
Then, a capsule-shaped node like this will be created
You can think of this capsule as a data node
It contains some values
Since it contains data, there is only one data pin
So, I will connect
this data pin to Print String
I will remove the data pin and connect it to this String
When I connect it, you can see that
an unwanted node is created in the middle
This is called a conversion node, and the variable we created is an Integer
which means it only contains integers, that is, integer data
However, the Print String node
says In String
That means only string variables and data types
can be inserted
So, since the data does not match
we need to convert the data
to match each other
This conversion node is what does that
In the case of Unreal Engine
this conversion node is automatically created
to help you work more conveniently
Let's take a look right away
If you compile, save
re-enter the level, and press the play button
you can see the number 100
printed in the upper left corner
Let's create another variable
This time, click the + button in VARIABLES
to create a data type container called Number2
This time, instead of Integer
let's choose Float
Float means a real number
A real number is a number that includes a decimal point
Of course, it includes integers 1, 2, 3, and 4
but it also includes decimal points, .5, .14
I think it would be better to say that it is a number that is
a slightly larger range than integers that includes numbers
after the decimal point like this
So, Compile and save
Let's get this Number2 variable
Drag & Drop, Get Number2
I'll connect it to this string
Let's connect it like this with Drag & Drop
Likewise, since the data type
is different
you can see that a conversion node was automatically created
Oh, I didn't enter a number
The default number, if you look at the default value of this variable
is 0.0
which shows that it can include a decimal point
Let's write it like this
Let's write it like 3.14
If you Compile, Save
and come back and play in this state
you can see that 3.14 is printed like this
When adding these functions, this player
must be stopped
That way, you can write the function properly
Let's create one more variable
Click the + button
to create a variable called Text1
As the name suggests, it will hold text
As we briefly mentioned in our Print String
text is stored using this String data type
Let's drag and drop to get the variable
called Get Text1 and connect it
If you connect it like this, there is no change node in the middle
because it is the same string
You can see that it is connected right away
However, this connected line
crosses these transformation nodes and is a bit messy
So, let's organize this line a bit
If you move it slightly to the side, place the mouse between these lines
and double-click
then, a new point will appear
A new pin will be created
You can grab this pin and move it
If you move it like this, you can organize it without it being too complicated
We haven't set a value for this Text yet
So Compile, save
and Unreal Engine, shall we say?
You can also input Korean in this string
If you Compile in this state
save
and play again
you can see that the phrase
Unreal Engine is printed like this
This time, we have a logical data type determining true or false
Is it a person? Is it not a person? Things like that
Are you playing? Are you not playing?
Some variables contain information values ​​that tell you
true or false, such as whether it is or is not
It is a logical data type
so I will name it isMan
This logical data type is the Boolean above
When we first created the variable, we briefly looked at Boolean
This Boolean variable contains the true or false variable
I discussed earlier
So regardless of the content
whether this is a person or not
playing or not
it only stores information about
whether it is right or wrong
If you compile and look at the classification value
you will find a variable named isMan
On the right, you can see a check box like this
So if it is disabled, it means False
If it is checked, True is saved
So, since
it is checked now
True is saved in the variable
Let's do this by bringing this variable
and connecting it
Since it is a Bool value, a conversion node will come out like this
If you compile, save, and play in this state
you can see that the True value is output like this
Earlier, we checked
Check means True
On the other hand, if we uncheck
the value of this variable and make it False
then when we compile, save, and play
the output will be False
We learned about four variables
If we only know these four variables
we can do many things
This time, by utilizing these variables
we will learn about
control statements that can create functions
Control means using
these variables
So let's start with
the simplest arithmetic operations
Since these variables were created for the introduction
let’s start by creating a new variable
First, click the + button
and this time, Number was used first
Let’s create a new name, Num, with the number 01
and the data type is Integer
Since integers are a little easier to improve
let’s create an Integer
Click Compile
and enter the number 100 in this number
Then, let’s create one more variable
Click VARIABLES and name it Num02
Again, let’s make it an Integer
Again, click the Compile button
and put 50 in this variable
If we do addition during the four basic operations, it will be 150
To make it easier
let’s bring in these two variables
Let's get Get Number1, Get Number2
by drag and drop
I'm going to add these two numbers
To add them, right-click on a space
and search for add
There's a node called Add
among the Operators
If you select Add, there's a node like this
You can think of this node as a node
that adds the input pins on the left
and outputs the result of the addition
So, input Num01, Num02 on the top left
and Num02 on the botton
And if we connect this result
back to Print String like this
we can see that it is connected
to Print String through conversion like this
Let's compile and check
Since we did addition, since it's 100+50
150 will be output
Let's see, let's play
How is it? 150 is output
We did addition, simple, right?
In addition to this, the addition node
becomes an addition when you add
It's the same
Minus, in English, it's subtract
If you search for subtract
the usage of the minus node is the same
You can connect the minus node and output it
and multiplication is the same
If you search for Multiply
you can also take out the Multiply multiplication node and use it
The method is the same
Division is the same
If you right-click and search for divide
a division node is created like this
In the same way, you can connect the results of dividing two variables
and see the final result
Here, the important thing is that if you want to create an addition node
and see the result
in a case like this, you come in
and put the number 50 in this variable at 102
and Compile, save
and play is a bit complicated
I just want to set it up right at this level
and see the result right away
but it would be quite a hassle
to go into the blueprint
set it up, compile, and go back and forth
So, we provide a function
to expose this node to the outside
As you can see
we are using
the Num01 and Num02 variables for addition
If you look on the right, there is an eye-closed icon
If you click this icon
it will change to an eye-open icon like this
Here's what happens
Compile and save it
If you select this actor
called BP_Basic that we uploaded
and look at the Details window
you can see that
there's a variable called Num01
exposed in the item called Default
You can also see that the value
is 100
Simple, right? Then, I'll expose the second one
If you click this button, or this button, in the Details window
select this variable
and then look at the Details window of this blueprint window
there will be an item called Instance Editable
You can see that it's checked
If you close your eyes, you can see that it's unchecked
Conversely, if you check here
you can see that your eyes are open
You can think of this item here as an item
that can be exposed to the outside.
So, if you compile and save it
now that we have selected the actor we uploaded
you can see the values ​​of two variables
in the Details window
Let's change it
Let's say this is 300
How much will it be?
Since it's a plus node now, it'll be 400
If you play, you can see that the number 400
is printed
Easy
We used variables to perform arithmetic operations
This time, we'll learn about conditional statements
A conditional statement is a structure that says "if ~~, then ~~"
In most programming, rather than executing unconditionally
like arithmetic operations
it's much more common to execute
only when a specific condition is met
For example, instead of just saying the door opened
say the door opened when the button was pressed
Or instead of unconditionally creating an enemy
say that an enemy is created after 2 seconds
That's what this means
So, let's make a simple conditional statement example
and go through it
We will compare
the variables Num01 and Num02
and if the number Num01
is much larger than Num02
print the message "Num01 is larger"
Otherwise, if Num02 is larger
If Num02 is bigger
If Num01 is not larger than Num02
print "2 is larger"
I'll put this condition
To do that, let's first
erase the plus in front
Since we're comparing these two variables
and outputting different outputs depending on the result
we need to compare them anyway
We need to compare these two variables
So, I will take out a node that compares two variables
Right-click We probably learned in math class
Comparing, greater than something
Or less than something, expressed with brackets
If you press brackets on your keyboard like this
you can take out a Greater node
Like this
So if you put Num01 in the pin above like this
and put the variable below like this
a node that says is Num01
greater than Num02 is created
This is called a comparison operator
So there are "big"
and "small," just like we learn in math class
There is "less"
There is "small" like this
and then there is Greater Equal
There are also things like Greater Equal
There will also be things like Smaller Equal
And there will also be things like this
There will also be "equal to"
We generally express "equal to" as =
but generally in coding, = is an assignment operator
that is used to input a value
So in coding, to express "equal to,"
we express it as ==
That is why the node called "Equal" comes out like this
== comes out
If there is "equal to", there must also be "not equal to"
In code, we put an exclamation mark in front
If we write "!="
this means "Not Equal"
In this way, we can compare two pieces of information
We want the variable in front
the Num01 variable, to be greater than the Num02 variable
So, we used the Greater node
Now, we've compared the two variables
So what we need to do now is
depending on the result values ​​of these two variables
if the Num01 variable is greater, we need to output "Num01 is greater"
and if Num02 is greater, we need to output
"Num02 is greater"
We have to do that
So, since the result value
from this comparison operator
is divided into two branches
we need another node
The node we need at this time
is called Branch
So, we take out the Branch node
This Branch node is executed in BeginPlay
and connected directly to the Branch
First, check what?
The result of comparing Num01 and Num02 is checked like this
and the result value is connected to the condition like this
When this result is true
what does it mean that it is true?
Num01 is greater than Num02
Oh, that's right, it's true
If you say that Num01 is greater, it goes to True
If you say that Num01 is not greater, it's False
You can think of it
as taking a branch that goes to False
Then, this is what you should do
If it's True
If you say that Num01 and Num02 are compared
and Num01 is greater
connect this True to the Print String
What you print at this time is that
Num01 is greater
That's a typo
When you compare the two nodes
do you say that 2 is greater than 1? No, 2 is greater
it should return False
In this False case, you print out that
Num02 is greater
so copy this node as it is
and press Ctrl+C and Ctrl+V
to connect it to the second node
No, Num02 is bigger
Connect it like this
This is a conditional statement
Using Branch
if the result of the condition in front is true
it will be connected to the True execution pin
and executed here
If the result is false
it will be executed using
the False execution pin below it
Compile and save
and look at the current case
Since Num01 has 100 and Num02 has 300
when comparing 1 and 2
it asked, “Is Num01 greater than Num02?”
if you look at it now, it’s not
It’s false, right?
Then, it will take a false line
Since it will take a false execution pin
No, Num02 is greater
will probably be the output
Let's see, let's play
How is it? It says that Num02 is bigger
This time, let's do the opposite
Instead of 100, let's try 500
Num01 is bigger, right?
Since Num01 is bigger than Num02
it will be true this time
Let's play
Then, it says that Num01 is bigger
This structure, conditional statements, is divided into branches
depending on whether the result of a calculation is true or false
So, we learned about arithmetic operations
and conditional statements
Event Graph Execution Order
We learned about nodes
This time, we will learn about the red nodes
These red nodes are called event nodes
You probably remember
these three nodes created
when you first opened the Blueprint Event Graph
These nodes are all called event nodes
Normal nodes are called by the execution pin on the left like this
and when it's time to execute
they're executed like this on the right
but these event nodes
don't have an execution pin on the left
and the Unreal Engine system automatically executes them
So when do these events occur?
If we connect it to this person
it will be a little easier to understand
What is this mean?
A person is born, lives, and dies
Usually, a life cycle is a series of processes
in a person's life
In a programming engine, when an object is created
each created object calls a specific event
according to this life cycle
So, when an object is created
it is like when a person is born
The node that is called exactly once
is the Event BeginPlay node
So, it is called once at the beginning
On the other hand, while the object is not destroyed and maintained
if we compare it to a person
it would be the entire time they are alive after birth
While it is not destroyed like this and is maintained
this Event Tick node is called repeatedly for each frame
while it is alive
It will calculate the entire code for each frame
and continue to show a newly updated image
for each frame
That is why we, the user, perceive movement
You can think of movement
as being expressed
through the Event Tick call
And there is a node called Event Destroyed
that is called right before an object like this is destroyed
which would be equivalent to death for a person
When we practice like this
to make it run only once
we connect this execution pin
to the Event BeginPlay node and the next execution pin
What if it's not this BeginPlay that's called first
but the Event Tick
it's down there?
Let's take a closer look
Let's break this down for a moment
Let's briefly break this down
and connect this phrase
that says Event BeginPlay
has been called to the event node
You may remember that we ran the phrase Hello World
once at the beginning
If you do BeginPlay, it will be called only once
If you compile, save, and play
you can see it's called
once like this
Let's connect this to Event Tick
What happens?
If you compile, save, and play
you can see that it is called on the left
and continues to be printed
It is continuously accumulating here
You can see that the one at the top
is called and calculated last
If you look from here to here
it is reading like this
You can see that it is reading like this
It reads once, then comes back and reads again
reads again, and reads again
and this is called Event Tick
And if you look at this event
Let's stop here
There's something called
Event ActorBeginOverlap
and this is related to collision
Begin, Tick, and then the collision-related event is there
because the object is alive
It can collide at any time
and as it lives, it can collide somehow
So, these three event nodes
always come out first like this
But as you can see, there's no Destroyed
This is because we don't know when this object will disappear
so that it can collide and disappear
Still, it may
or never disappear
So in cases like Destroyed
the developer is told to take it out whenever he wants
so it doesn't come out first by default
So, three things come out like this
Did you get it?
So, I think we've covered the basic theory of
blueprints to some extent
With this level of basic theory
you can create most functions
So in the next video, we'll create simple functions
based on this theory
So, let's summarize what we learned in this session
Understanding Blueprints and Blueprint Scripting Blueprints Unreal's own design system designed to design complex actors Visual scripting system
Blueprint Scripting Create a new folder in the Content folder and save it as BP Right-click on an empty space in the BP folder and select Blueprint Class
After selecting the Actor class, set the Blueprint class name to BP_Basic Go to the Event Graph panel, right-click on an empty space, and create a Print String node
Enter Hello World in the Print String node and connect it to the Event BeginPlay node execution pin Drag the BP_Basic blueprint class and place it in the world
When running, check that the phrase 'Hello World' is displayed in the upper left of the viewport Node structure and flow
Blueprint Node Configuration: Execute Pin, Input Pin, Output Pin Data flow is executed from left to right
Data Type and Blueprint Arithmetic Operations Variables A container that can hold each piece of data Data Type: The type of data that a variable can have
Basic data type: Data type determined when creating a programming language User-defined data type: Data type created according to the development situation
The most commonly used primitive data types: Float, Integer, String, Boolean
Entering variables Use the [+] button in the Variables item to declare an integer variable Number1 and compile/save Enter the value 100 in the Number1 variable
Drag and drop the Get Number1 variable to the Event Graph Connect the output pin of Number1 to the In String input pin of Print String
After compiling/saving and running, check that '100' is printed in the upper left corner
Blueprint Arithmetic Operations Declare integer data type Num01, Num02 variables using the [+] button in the Variables item Add Add node
Add integer variables Num01, Num02 to the input pins, then connect the output pin to the In String pin Subtract, Multiply, and Divide are the same way
Conditional statement The structure of 'if ~ then ~'
Branch node - The flow of execution is divided into True/False depending on the result of the conditional expression Compare the two values ​​and output which one is larger
Event Graph Execution Order Event Graph Execution Order Life Cycle: The cycle of being born, living, and dying
Each created object calls a specific event according to its life cycle When first created: [Event Begin Play] - occurs once
While alive: [Event Tick] - Called repeatedly every frame, continues to show updated image every frame When dead: [Event Destroyed] - object is destroyed