Flow Control

Unreal Engine 4: Intro to Game Design Blueprint Scripting Fundamentals - (FOR BEGINNERS!!!)
14 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€92.85
List Price:  €130
You save:  €37.14
£79.68
List Price:  £111.56
You save:  £31.87
CA$136.70
List Price:  CA$191.38
You save:  CA$54.68
A$151.38
List Price:  A$211.94
You save:  A$60.56
S$134.98
List Price:  S$188.98
You save:  S$54
HK$781.15
List Price:  HK$1,093.64
You save:  HK$312.49
CHF 90.48
List Price:  CHF 126.67
You save:  CHF 36.19
NOK kr1,087.35
List Price:  NOK kr1,522.33
You save:  NOK kr434.98
DKK kr692.92
List Price:  DKK kr970.11
You save:  DKK kr277.19
NZ$166.35
List Price:  NZ$232.90
You save:  NZ$66.55
د.إ367.25
List Price:  د.إ514.16
You save:  د.إ146.91
৳10,943.35
List Price:  ৳15,321.13
You save:  ৳4,377.77
₹8,337.18
List Price:  ₹11,672.39
You save:  ₹3,335.20
RM473.95
List Price:  RM663.55
You save:  RM189.60
₦123,487.65
List Price:  ₦172,887.65
You save:  ₦49,400
₨27,847.21
List Price:  ₨38,987.21
You save:  ₨11,140
฿3,675.50
List Price:  ฿5,145.85
You save:  ฿1,470.34
₺3,235.04
List Price:  ₺4,529.19
You save:  ₺1,294.14
B$507.19
List Price:  B$710.09
You save:  B$202.90
R1,850.71
List Price:  R2,591.07
You save:  R740.36
Лв181.51
List Price:  Лв254.13
You save:  Лв72.61
₩135,590.93
List Price:  ₩189,832.73
You save:  ₩54,241.80
₪371.66
List Price:  ₪520.34
You save:  ₪148.68
₱5,705.78
List Price:  ₱7,988.32
You save:  ₱2,282.54
¥15,304.96
List Price:  ¥21,427.56
You save:  ¥6,122.60
MX$1,696.83
List Price:  MX$2,375.63
You save:  MX$678.80
QR364.06
List Price:  QR509.70
You save:  QR145.64
P1,358.38
List Price:  P1,901.79
You save:  P543.40
KSh13,211.65
List Price:  KSh18,496.84
You save:  KSh5,285.18
E£4,788.95
List Price:  E£6,704.73
You save:  E£1,915.77
ብር5,723.72
List Price:  ብር8,013.44
You save:  ብር2,289.71
Kz83,591.64
List Price:  Kz117,031.64
You save:  Kz33,440
CLP$94,219
List Price:  CLP$131,910.38
You save:  CLP$37,691.37
CN¥723.65
List Price:  CN¥1,013.14
You save:  CN¥289.49
RD$5,794.19
List Price:  RD$8,112.10
You save:  RD$2,317.90
DA13,457.95
List Price:  DA18,841.67
You save:  DA5,383.72
FJ$225.30
List Price:  FJ$315.43
You save:  FJ$90.13
Q775.06
List Price:  Q1,085.12
You save:  Q310.05
GY$20,860.22
List Price:  GY$29,205.14
You save:  GY$8,344.92
ISK kr13,962.60
List Price:  ISK kr19,548.20
You save:  ISK kr5,585.60
DH1,005.73
List Price:  DH1,408.07
You save:  DH402.33
L1,766.28
List Price:  L2,472.87
You save:  L706.58
ден5,712.05
List Price:  ден7,997.10
You save:  ден2,285.05
MOP$802.57
List Price:  MOP$1,123.63
You save:  MOP$321.06
N$1,845.78
List Price:  N$2,584.16
You save:  N$738.38
C$3,670.67
List Price:  C$5,139.09
You save:  C$1,468.41
रु13,313.56
List Price:  रु18,639.52
You save:  रु5,325.95
S/372.22
List Price:  S/521.13
You save:  S/148.90
K385.44
List Price:  K539.63
You save:  K154.19
SAR375.01
List Price:  SAR525.03
You save:  SAR150.02
ZK2,689.66
List Price:  ZK3,765.63
You save:  ZK1,075.97
L462.03
List Price:  L646.86
You save:  L184.83
Kč2,326.92
List Price:  Kč3,257.79
You save:  Kč930.86
Ft36,193.38
List Price:  Ft50,672.18
You save:  Ft14,478.80
SEK kr1,078.64
List Price:  SEK kr1,510.15
You save:  SEK kr431.50
ARS$87,815.44
List Price:  ARS$122,945.14
You save:  ARS$35,129.69
Bs690.51
List Price:  Bs966.74
You save:  Bs276.23
COP$388,367.89
List Price:  COP$543,730.59
You save:  COP$155,362.69
₡50,962.55
List Price:  ₡71,349.61
You save:  ₡20,387.06
L2,463.20
List Price:  L3,448.58
You save:  L985.38
₲746,475.93
List Price:  ₲1,045,096.16
You save:  ₲298,620.23
$U3,821.56
List Price:  $U5,350.33
You save:  $U1,528.77
zł401.98
List Price:  zł562.79
You save:  zł160.80
Already have an account? Log In

Transcript

Hey everyone, in this video tutorial we are going to be talking about what flow control nodes are within blueprints scripting. So what you see in front of you right now I am within my Level Blueprint, I simply came under blueprint Level Blueprint are a bunch of flow control nodes that you can utilize when scripting your game. Now what are flow control nodes? Well, flow control nodes allow you to choose what script or what functionality executes based on whatever conditions you put in place. So some examples that I can think of is you can decide if a door in a game is locked or unlocked. based on whether or not you have a key.

Does the player have the key true or false, right? You can make it so that you can interact or open a chest once to get the goodies out of it and then never again that's another example. So in the two examples, decided whether or not you can open up a door based on whether or not you have a key, you would use a flow control node called a branch node. In the example that I gave of interacting or opening a treasure chest just wants to get the goodies out of it. But then never again, you would use a flow control nodes such as do once you can open it up once and never again. So all these are examples of flow control nodes.

And how did I get these? Well, within your right click menu right here, if you just do a search for flow control, you're going to see a whole selection of different flow control nodes. There's a bunch of them here, these do n do ones flip flop, we're gonna examine some of these. There's some more programmer ones like for loops, and while loops we're not going to get into and then there's a whole series of switch on various names right here. We're going to explore just one today called switch on So let's demonstrate because seeing is believing, let's demonstrate a few of these nodes at work. The first one we're going to try here is the branch node.

And to help me get started here, I'm just going to bring in an event. So I'm going to right click, type in H will bring in an H key press event. And next thing I'm going to do is I am going to hold down the B key, B as in boy, and I'm going to left click to bring in a branch note that one's got a shortcut to it because it is very commonly used. Okay, next, I'm just going to right click and do a search for a print string node. And I'm actually going to hit Ctrl C with that highlighted and Ctrl V to paste Ctrl C Ctrl V, because I want two copies of this. And I'm going to drag and drop a wire from my true pin here to my Print string up here, then out of the false pin.

I'm going to plug this into my print string down here. And what I'm going to do is in this top most print string, I'm going to type in the word true. And in the bottom area, I'm going to type in the word false. So now when I press the H key, this branch node is going to evaluate whatever condition I have here. checkmark means true, and it'll fire out of this true branch right here. If I uncheck this, that would mean the condition is false.

And it would fire out of this pin and print false to the screen. Now note, I could plug in a variable here, I could create a variable called Heck, we could call it has the key question mark. And then we could compile because it's telling us to compile And I could click on this little checkbox right here to say yes, he does have the key. So I could even plug in a boolean variable right here saying yes, I do have the key to then show that yes, I have the, the key. Let's see this in practice. If I press the H key right now, I do have the key because I checked Mark Yes, over in the Details panel for this variable.

So I should see the word true. Okay, so pressing the H key right now look in the upper left hand corner of the screen, you can see it says true. Now if I change the value of this variable to false, now I'm saying I do not have the key that is false, so I should see the word false when I press the H key. Okay, now let's do a quick sampling of showing off what to do once no does I'm just going to delete out this has key variable to delete out my branch, we will delete out one print string. And I will drag in my do once note here. And let's hook up a sequence like this.

And when I press the H key, we're going to one time, print out this string. So I'm going to change the text here to say, done. Alright, so this should execute, only the first time I press the H key. If I press it again, it should not print the word done. So here we go, hit play. The first time I hit the H key, you see the word done.

Now on subsequent presses of the H key, you do not see it. However, there is this input pin over here where I can reset it and make it so that after I press it, I can allow it to go again. So what I could do here off of my print string node is add what is called a delay node. And I could set this for a duration of, let's say, one second for five seconds, and then I'm going to drag a wire off of my completed and plug this back into my reset. So what I'm saying here is Once I press the H key, just one time, we will print the string that says done. And then after five seconds, I will be allowed to do it again.

So here we go. gonna hit play. Pressing H key shows the word done. Now if I press it again, nothing but if I wait five seconds, I believe five seconds has passed. I can press it again and it shows up. So that is a do one snowed in practice.

Next, let's go on to the flip flop node. So I'm going to delete this do once node out here. We don't need that guy. I'm going to delete out my delay. No, let's bring in the flip flop. Okay, what I'm going to do is hook it up.

Like this, and I'm going to duplicate my print string, select it Ctrl C to copy Ctrl V to paste. And I'm going to plug a into there and B into there. So what the flip flop node does is every time I press the H key is going to fire out the a branch first, then the B branch, then the Abraham branch, then the B branch, so every time I press it, it's going to select a different branch. Okay, so in this topmost one, I will type in the word flip, bottom node, I will type in flop, so it will alternate between those two words every time I tap the H key so here we go. Flip Flop, flip flop, flip flop, you get the point. Okay, next, let's go on to the sequence node.

Gonna delete out this flip flop node. Let's bring in the sequence node here. Now the sequence node comes in handy. Because there are certain events, such as Event Begin Play and Event Tick, that you can only have one copy of in your Event Graph. So what happens if you want multiple things to fire off of that one event? Well, what you can do is you can add a sequence node here, what a sequence node allows you to do is wire in one event, for example.

But then output as many signals as you want. It's kind of like splitting the signal. So what's going to happen here is I'm going to hook this in like this. Actually, I'm going to delete some of these, you can right click on these to remove execution pin. And I'm going to hook this one up here, and then this here, so the sequence node is going to fire off every thing in the list in a rapid succession. So fast in fact, it will seem simultaneously simultaneous So actually, let me add one more pin here.

And I'm going to Ctrl C and Ctrl V one more print string. So what I'll do is I'll change this to be a value of one up here, to right here, and three down below, instead. So now when I press the H key, I should see in the upper left hand corner, one, two and three appearing very rapidly. Okay, so pressing H key right now. There you go. Now the reason I saw it is 321, because it actually printed out 123.

It just kind of pushed the numbers on down the screen as I pressed it. Okay, so that's the sequence node, it will fire off everything in the list in rapid succession super fast that it will seem simultaneous. Just a couple more to explore here. Let's try out the gate node, shall we? I'm going to delete out our sequence. No, we don't need that anymore.

I'm going to delete out to print strings. I'm going to bring In a gate node. So with a gate node, you can actually determine if the flow of execution here is open or closed, we can enter into this pressing the H key will enter into this gate. But for starters, it is not going to be open. So I'm just gonna type into our print string over here, gate. Gate is now open.

Okay, but this node right here says by default, we are starting close. So if I press the H key will enter into this, but again, is currently closed. And so this will never fire. So I'm just going to jump in and play. And I'm going to tap that H key. And you'll see we don't get that text printed.

Because we have not opened the gate we need something to open the gate to allow this print string to display on screen. So what I'm going to do here Here is hooked up the releasing of the H key to open the gate. So what will happen is I'm going to press the H key, we're going to enter this gate, it's going to start off close because it starts off close, nothing will happen. But as soon as I release the H key, the gate will then be open. And so on my next press after that my second press of the H key, we will fire out of this execution pin and this string will be printed. So let's give it a try pressing the H key once don't do anything, releasing the H key so the gate is now open.

And I'll pressing the H key again. The gate is now open. So that is the gate node next one last one, in fact, will be switched on in so I'm going to delete this out. Let's bring in our switch switch on int node right here. gonna hook this in like this in just like our secret snowed are switched on in Node allows us to add some pins. So let's click on a couple right here.

Let's add a couple. And what I'm going to do is I'm going to copy and paste a string here. Let's hook these guys up like this. I'm going to call this one string number one. And this one is going to be called string number two. So what the switch on it allows us to do is it allows us to fire out of whichever execution pin is within this numbered box right here.

So in this case, if I press the H key, it's going to select pin number zero to fire out of not one. So once I jump in, it should press it should print string number one to the screen as soon as I press the H key. So let's give this a try. I'm pressing the H key and it shows string number one now I change this selection to be number one will now press the H key in, it'll fire out of this one branch right here, this one pin, which, which should print string number two. There you go. And you can add as many of these as you want.

This is a really good way to create a randomize a randomized system of sorts. For example, I've got five pins out here, what I could do is I could drag out of this guy right here, and I could look for a node called random integer in range. And what I can do is I can specify a min value of zero and a max number of, say, four. So what I'm telling the switch on int node to do here is to pick a number between zero and four and then fire out of whichever number it picks. So I wanted to skew the odds here. So that string number one is Printed four out of five times 80% of the time and 20% of the time it prints out string number two, I could have a setup such as this so let's give this a play and press the H key one time it chooses string number one, that time is chose string number two, just spamming the HQ now so you can see the results.

And that is what is switch on node is used for. Alright, so that's going to cover it for flow control nodes. We will see you guys in the next one

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.