Functions

Unreal Engine 4: Intro to Game Design Blueprint Scripting Fundamentals - (FOR BEGINNERS!!!)
10 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
€93.41
List Price:  €130.79
You save:  €37.37
£79.90
List Price:  £111.86
You save:  £31.96
CA$137.16
List Price:  CA$192.03
You save:  CA$54.87
A$153.08
List Price:  A$214.33
You save:  A$61.24
S$135.90
List Price:  S$190.27
You save:  S$54.36
HK$781.66
List Price:  HK$1,094.36
You save:  HK$312.69
CHF 91.23
List Price:  CHF 127.73
You save:  CHF 36.49
NOK kr1,107.76
List Price:  NOK kr1,550.92
You save:  NOK kr443.15
DKK kr696.86
List Price:  DKK kr975.63
You save:  DKK kr278.77
NZ$168.60
List Price:  NZ$236.05
You save:  NZ$67.44
د.إ367.24
List Price:  د.إ514.16
You save:  د.إ146.91
৳10,972.60
List Price:  ৳15,362.09
You save:  ৳4,389.48
₹8,346.11
List Price:  ₹11,684.89
You save:  ₹3,338.77
RM475.54
List Price:  RM665.78
You save:  RM190.23
₦123,487.65
List Price:  ₦172,887.65
You save:  ₦49,400
₨27,846.85
List Price:  ₨38,986.71
You save:  ₨11,139.85
฿3,694.58
List Price:  ฿5,172.56
You save:  ฿1,477.98
₺3,236.41
List Price:  ₺4,531.11
You save:  ₺1,294.69
B$519.35
List Price:  B$727.11
You save:  B$207.76
R1,861
List Price:  R2,605.48
You save:  R744.47
Лв182.73
List Price:  Лв255.83
You save:  Лв73.10
₩137,535.16
List Price:  ₩192,554.72
You save:  ₩55,019.56
₪374.71
List Price:  ₪524.61
You save:  ₪149.90
₱5,763.02
List Price:  ₱8,068.46
You save:  ₱2,305.43
¥15,525.12
List Price:  ¥21,735.79
You save:  ¥6,210.67
MX$1,695.96
List Price:  MX$2,374.42
You save:  MX$678.45
QR364.20
List Price:  QR509.89
You save:  QR145.69
P1,420.18
List Price:  P1,988.32
You save:  P568.13
KSh13,372.99
List Price:  KSh18,722.73
You save:  KSh5,349.73
E£4,798.26
List Price:  E£6,717.75
You save:  E£1,919.49
ብር5,719.92
List Price:  ብር8,008.12
You save:  ብር2,288.20
Kz83,641.63
List Price:  Kz117,101.63
You save:  Kz33,460
CLP$96,028.39
List Price:  CLP$134,443.59
You save:  CLP$38,415.20
CN¥723.89
List Price:  CN¥1,013.48
You save:  CN¥289.58
RD$5,819.58
List Price:  RD$8,147.64
You save:  RD$2,328.06
DA13,455.35
List Price:  DA18,838.03
You save:  DA5,382.68
FJ$226.17
List Price:  FJ$316.65
You save:  FJ$90.48
Q777.12
List Price:  Q1,088.01
You save:  Q310.88
GY$20,929.88
List Price:  GY$29,302.67
You save:  GY$8,372.79
ISK kr14,022.59
List Price:  ISK kr19,632.19
You save:  ISK kr5,609.60
DH1,011.06
List Price:  DH1,415.53
You save:  DH404.46
L1,768.33
List Price:  L2,475.73
You save:  L707.40
ден5,750.59
List Price:  ден8,051.06
You save:  ден2,300.46
MOP$805.69
List Price:  MOP$1,128
You save:  MOP$322.31
N$1,863.42
List Price:  N$2,608.86
You save:  N$745.44
C$3,672.13
List Price:  C$5,141.13
You save:  C$1,469
रु13,425.24
List Price:  रु18,795.88
You save:  रु5,370.63
S/376.35
List Price:  S/526.91
You save:  S/150.55
K385.89
List Price:  K540.26
You save:  K154.37
SAR375.01
List Price:  SAR525.03
You save:  SAR150.02
ZK2,677.10
List Price:  ZK3,748.04
You save:  ZK1,070.94
L464.84
List Price:  L650.79
You save:  L185.95
Kč2,347.91
List Price:  Kč3,287.17
You save:  Kč939.26
Ft36,370.18
List Price:  Ft50,919.71
You save:  Ft14,549.52
SEK kr1,092.76
List Price:  SEK kr1,529.91
You save:  SEK kr437.15
ARS$87,614.14
List Price:  ARS$122,663.30
You save:  ARS$35,049.16
Bs690.85
List Price:  Bs967.22
You save:  Bs276.36
COP$390,329.27
List Price:  COP$546,476.60
You save:  COP$156,147.32
₡51,017.42
List Price:  ₡71,426.43
You save:  ₡20,409.01
L2,476.75
List Price:  L3,467.55
You save:  L990.79
₲749,236.02
List Price:  ₲1,048,960.40
You save:  ₲299,724.38
$U3,833.15
List Price:  $U5,366.56
You save:  $U1,533.41
zł404.64
List Price:  zł566.52
You save:  zł161.87
Already have an account? Log In

Transcript

Hello again in this video tutorial we are going to be talking about functions in the Unreal Engine functions in blueprints scripting are simply nodes that perform some sort of functionality, whether it's playing a sound displaying a message, or spawning an enemy. So I'd like to demonstrate some more of these functions within the engine. And to help me in that discussion, I'm going to use our Level Blueprint and you can access your Level Blueprint by coming under this blueprints button right here and clicking on open Level Blueprint. Within this event graph right here, I have pre placed some function nodes within here that we're going to demonstrate in just a minute. Now, where do you get these nodes right here, these function nodes, and again, functions have these sort of blue looking header with the fancy looking at where you can find a lot of Have these by simply just right clicking anywhere within the Event Graph here.

And then you've got a whole bunch of different categories here that if you click on any of these drop down triangles here, there are different functions that may exist within all of these headings right here. Now these are some more of the common functions that I know of within the engine. So we're going to demonstrate these because these are commonly used. This first one here is a play sound 2d, often used for stuff like playing music within your level. And to just demonstrate this, I'm going to use an H key press event on my keyboard. So I'm just going to link this node together with my play sound 2d.

And as soon as I click play, and then I press that H key you can see that I've kicked off some game music. So that's the place sound 2d function. I'm just going to hold down the Alt key and left click to break this link right here. The next one I'm going to demonstrate here is a function node called spawn actor. It's actually called spawn actor from class. But once you slot in which class you would like to spawn in, it changes the header here.

So this is actually a spawn actor from class node in the particular class that I am going to be spawning in here is a blueprint explosion. And I've just simply specified a location within the level I want this to play out. So when I press the H key in here, I can just keep spawning explosions again and again. So that's a pretty cool and useful node spawn actor from class. Next function we're going to demonstrate here is a set actor relative location. So something I have done here is I have each share within my level and I have Simply hooked up this chair to a set actor, location node and what's going to happen as soon as I press the H key for this guy, I'm going to take my chair that exists right here and when I press the H key, I'm just going to move it over there where I told it to move.

So this is another commonly used no there's a set actor relative location and set world location function nodes those are commonly used. I'm just gonna hold down the Alt key left click to break that link right here. Destroy actor This is a common function is well and I need to specify which actor I would like to destroy. So I'm just going to link this to my chair here. don't really need to have it linked to this set actor location anymore, so I'm just going to break that and if I now press the H key within my level, I will destroy that chair actor. So that is a Another commonly used function.

Another one I would like to demonstrate quickly here is a node called toggle visibility. If I jump back to my level here, you can see I've got some texts up here. This is known as a text render actor that just says Unreal Engine is awesome. And what I'm going to be aiming to do here is I'm going to talk to this text render actor. And what I'm going to do is when I press the H key, this function is going to do exactly what it says here, it's going to toggle the visibility. So I press it once it's going to go away, I press it again, it's going to come back, etc.

So press it once goes away and press again, it comes back, so on and so forth. Okay, so those are some commonly used functions within the Unreal Engine. One really cool thing about Unreal Engine is that you are not limited to the functions that they have already made for you for you to use. You can actually create your own functions and the place you do that within this level. blueprint. And even you can do it in something called class blueprints is this area called the My Blueprint panel.

And in this area of the my blueprints panel there is a section called functions. And if you roll on over to the right of that header, there is a plus function button, go ahead and left click on this guy. And we're going to create our own function. This one we are going to call add points together. And I'm going to hit enter here. And you can see that as soon as we clicked on this plus function button, and we were prompted to give it a name, a new tab was added up here.

Now within this tab, this is where we are going to define what this function should do. So this is how it's going to work. Think about it, we're going to add two numbers together in this particular function, and we're going to output the result of the adding of those two numbers. So the way we're going to do that is first of all, we need to give this function two inputs. So over here in this details fan, I'm going to click on this plus button for input. And I'm going to call this first input, simply points, and then I'm going to hit Enter.

And I'm going to click on the plus button one more time. What's important to note, we want this to be an integer. Variable Type. integers are whole numbers like 654 hundred, they're a non decimal number. click on this plus button again, we're going to call this input more points. We also want this to be an integer.

So go ahead and hit enter here. In for outputs, we just want one so I'm going to click on this new parameter here. And I am going to call this let's call it final points and hit enter. Now what we want to do between this entry node here and this return node here is define the functionality that we want to create. So this is what we're going to do, we're going to drag a wire off of our points here. And we're going to hit the plus symbol.

And we're looking for a node called integer plus integer. We're going to plug points into that in more points into the bottom pin here. And this node here is going to add these two numbers together. And it's going to output the result. So we'll plug this into our final points here. And this is going to be what our function does, it's simply going to add these two numbers together and output the total.

So make sure you compile here. And then when we jump back to our Event Graph, what we can do is we can actually make use of our new function, so I'm just going to drag and drop our new function into the graph. left click and drag. And you can see now that along the left hand side of our new function, we have two inputs, points in more points, the target pin comes with automatically. And we have one output final points. So just to kind of draw this, or to hammer this point home here are our inputs, points in more points, which is similar to our inputs right here points in more points in our output final points, comes out right here.

So in a way, you could kind of think of it as the function node kind of created like this right with our points in more and more points being showing up on the left side of the node. And the final points the output node showing up on the right side of the node. So if you imagine my rectangular shape here being our new function, though, that is essentially what we just created and at the heart of it instead This is where we are adding those two point totals together. So jumping back to our event graph here, I'm going to unhook our HQ in here, bring this down, I am simply going to punch in some hard values here, I'm going to punch in a value of five points, and we'll say 10 for more points, and obviously five plus 10, is 15. Then I'm going to drag a wire out of this and do a search for print string.

And what this function node is going to allow us to do is print whatever string we want to the screen. So I'm going to click on that little down arrow here because I want this text duration to last on the screen for let's say, five seconds, and I'm also going to make it a pinkish color to make it a little bit easier to see. Now we need to give it an input. We want to have our final points printed to the screen. I'm just going to drag out of here and plug it into here and it's going to bring in this little conversion node which is going to convert an integer to a string. We'll learn about variables more in a little bit.

And I'm just going to compile and now when I jump in and play, and I press that H key look in the upper left hand corner 15 Well, there you have it. So that is our discussion on functions. We're going to continue our discussion here on scripting a little bit more. Next we are going to be talking about variables. So 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.