Scribe
Scribe

ชอบมันไหม? ทำให้ Scribe ดียิ่งขึ้นโดย การให้คะแนน

รับส่วนขยาย Chrome

เรียกดู

  • วิดีโอยอดนิยม
  • วิดีโอล่าสุด
  • ช่องทั้งหมด

เครื่องมือฟรี

  • ตัวดาวน์โหลดคำบรรยาย
  • ตัวสร้างเวลา
  • ตัวสรุปวิดีโอ
  • ตัวนับคำ
  • ตัววิเคราะห์ชื่อเรื่อง
  • ค้นหาบทถอดความวิดีโอ
  • การวิเคราะห์วิดีโอ
  • ตัวสร้างบท
  • ตัวสร้างแบบทดสอบ
  • แชทกับวิดีโอ

ผลิตภัณฑ์

  • ราคา
  • บล็อก
  • รับส่วนขยาย Chrome

Developers

  • Transcript API
  • API Documentation

กฎหมาย

  • ข้อกำหนด
  • ความเป็นส่วนตัว
  • การสนับสนุน
  • แผนผังเว็บไซต์

ลิขสิทธิ์ © 2026 สร้างด้วยความรักโดย Scribe

— ถ้านี่ทำให้ชีวิตของคุณง่ายขึ้น (หรืออย่างน้อยก็วุ่นวายน้อยลง) กรุณาให้คะแนนเรา! เราสัญญาว่ามันจะทำให้วันของเราดีขึ้น 😊

Related Videos

Learn to Code in UE5 - 7 - Code Execution Flow

Video thumbnail
20.19k3,861 คำ19m readGrade 18
แชร์
Channel
Coqui Games
[Music] hello everyone and welcome back to the course in this lesson we'll take a look at code execution flow we will learn about nodes that allow us to execute code based on specific conditions restrict execution or simply allow us to repeat a certain part of our code several times all of this will give us the ability to control the order in which our code executes within our game let's get started and now that we're back into unreal let's go ahead and remove these top notes here from our previous example right click and search for sequence go ahead and select it and this node does exactly what it says it executes code in a sequence so what we're going to do is recreate a previous example that we've used in the lesson before by first shuffling our array so go ahead and connect the first pin to shuffle and second we want to simply display index 0. so here we are getting the results of index 0 and we simply use print string to see the results [Music] and connect then 1 to print string and if you double click on any of the execution wires like so you create what is called a reroute node and this is a way of organizing the wires so click and drag to organize the results and then simply connect the event begin play to the sequence node let's go ahead and compile and go back to our level now click on simulate and in this case we get cookie games stop simulate again and in this case we get epic games let's go ahead and stop and go back to our blueprint as you can see we are simply executing the shuffle first and then grabbing the first index and displaying them again we can continue to add more and more pins to the node to execute code in a sequence now let's go ahead and remove all of the nodes from this example and now right click and search for flip flop this node simply executes path a and b in an alternating manner in other words when you first call the node it'll execute a but when you call the node again it'll execute b it we'll simply alternate between a and b infinitely so for this example we'll do something quite simple we'll simply grab our my array variable [Music] and get the value of our first index and in this case we'll simply print the results now let's go ahead and copy those notes paste them at the bottom and connect them to b we'll use a reroute node here this way we keep the code organized but instead of printing the results of index 0 we'll change this to index 1. now we'll connect the event begin play to flip-flop and we'll do another reroute node in between finally we'll drag from the print string at the top all the way to the reroute node here and we'll do this other two reroute nodes to keep the code organized basically we're calling the flip flop node once it will execute path a which will print the results of index 0 then this node will go back and call the flip-flop node again but this time flip-flop should now go through path b and then print the results of index 1.
let's go ahead and compile and go back to our map and click on simulate as you can see it printed index 0 and then index 1. let's go ahead and stop and go back to our blueprint this isn't the best example normally you would do this for more practical examples such as a light switch would be a great example where the player would simply interact with a light switch and every time the player would interact the light would either turn on or off but for this lesson we'll stick to the array example for this next example we have a node that guarantees that our code will be executed just once so go ahead and right click and search for do once and select it and for the example we'll copy these nodes right here and we can go ahead and delete all of the nodes connected to the gameplay now simply connect event tick to the print screen here and let's compile and go back to the map if we click on simulate you'll notice that we're simply printing index zero indefinitely let's go ahead and stop and go back to our blueprint but now if we connect the do ones node in between this code will only be executed once so let's test that out click compile go back to our map and click on simulink as you can see cookie games only printed once let's go back very simple note but very useful this next example is very similar to do ones and is the node is called do n so go ahead and right click search for do n [Music] and in this case you'll have to scroll all the way down until you find it so you can see it right here go ahead and select it and we'll simply replace the do once node with the do n node and as the node name implies this will simply allow the execution of its code n number of times so in this case n0 means it will not be executed but if we change this to 1 we are effectively creating a do once node so let's try that out compile go back to our level and click simulator as you can see again cookie games only prints once stop let's go back to our blueprint but obviously in this case you can specify how many times you want this action to be executed until the node basically locks its execution path from executing again so in this example again we'll just put three compile go back to your map and click simulate and as expected it prints cookie games three times let's go back to our blueprint this note is useful if you want to cap the amount of times an action is allowed to happen and again notice that we do have a reset pin here so during gameplay you can go ahead and reset the counter and allow the node to execute again [Music] so let's go ahead and remove these notes and the next note is perhaps the most common flow control technique in programming and that is called the if statement in unreal it is called the branch node so go ahead and right click search for branch and select the node this node has two output pins a true and a false and will execute based on a condition which happens to be a boolean and as we know a boolean can be true or false so for our example let's go ahead and drag our array and use the contain node and in this case let's go ahead and click on our array and copy the first one here cookie games and paste it in here let's go ahead and connect it and we'll simply use a print string to let us know if it found the item or if it did not find the item so let's go ahead and add our print strings and for this example i'll simply add item found now go ahead and copy the same node and connect it to false but this time add item not found go ahead and compile go back to our map and click on simulate as you can see it says item found let's go back to our blueprint and let's simply add an additional character to cookie games let's go ahead and compile go back to our map and click on simulate as you can see it said item not found let's go back to our blueprint very simple note but extremely useful you'll find that we're going to be using this node extensively as we go along the course and continue to use more and more complex examples let's go ahead and remove the notes for these three examples we will use what are called loops a loop is a simple way of repeating an action a certain number of times so the first thing we'll use is called a for each loop so right click and search for four each go ahead and select it and you'll see that the node has an execution pin and a connection to an array this node will simply execute for every single element in the array so if we simply drag our array and connect it as so you'll see that now we have a few things going on here we have a loop body we have an array element and an array index this node will execute its loop body for every single element in the array in this case we have three elements index zero through two so it'll execute three times and every time it executes it'll return the actual array element which is a string and the index starting from zero when it completes all of this it'll then execute the completed pin so you can see here so a simple example would be to print all of the elements of our array and we can do that by simply using a print string like so as you can see for every item the loop body will execute a print string and will simply print the array element as so let's go ahead and connect the begin play and finally let's do another print string at the end to make sure that the note completed for this example enter completed now let's go ahead and compile let's go back to our map and click on simulate notice that we have all of the array elements printed with completed at the end go ahead and stop let's go back to our blue this is a very common example of how we can iterate or go through all of the elements of our array and perform a certain action the next loop type is called a for loop so go ahead and right click and search for for loop and here at the bottom you'll see that we have two for loop in for loop would break go ahead and select the first one and you'll notice that we have very similar output nodes here we have a loop body we have an index and we have a completed however instead of taking in an array it'll simply repeat an action between the first and the last index so if we wanted to replicate this exact setup we could do it with a for loop we know by clicking on our array that we have three elements in our array so if we go from zero to 2 we'll go through all of the items in our array and we can simply copy our array like so and use a get node and then we can print this to the screen this is an example we've done on our previous lesson but now we're integrating that with a for loop so if we connect this to the loop body we will then print element 0 every time we iterate between the first and last index but lastly if we connect the index from the loop to the actual input pin of our get we will now effectively print every single item on the array between index 0 and 2. and if we copy this node here and connect it to complete it you'll see that we have effectively done the exact same setup as above so go ahead and connect beginplay to our for loop like so compile and now let's go back to our map click on simulate and as you can see we have the exact same setup go ahead and stop and go back to our blueprint in this case we match that exactly to our array but notice that you can obviously change the numbers here and do something to a subset of the array for this next example let's go ahead and remove all of the nodes that we have here right click and search for a while loop go ahead and select it and this loop will execute as long as the condition here is true this loop is useful when we don't know exactly how many times we need to repeat an action as long as this condition here is true the loop body will be executed and the node will be called again notice that this means that if the condition never turns to false the loop will continue to execute indefinitely this is called an infinite loop and it'll typically crash your program unreal is smart enough to detect an infinite loop it will simply stop execution so we will try again on this example to recreate what we have done with the other two loops but this will be a little bit more advanced because we need to now take care of the condition to make sure that we do not have an infinite loop so the first thing we need to do is make sure that we print our elements to the screen as before so go ahead and drag your array select get and let's use the get node here as before and use the print string let's go ahead and connect the loop body and now we see that we are simply printing element of index 0 every single time the loop body executes however we want to make sure that we update the index value here so we can iterate through all the elements of our array the easiest way to do this is to simply create a variable that will keep track of the index that we need to use here so go ahead and right click and select promote to variable and in this case let's call this variable counter compile and as you can see we are now using the counter variable which has zero by default to grab our element that we want to print on the screen however since we want to go down the array element 0 index 0 index 1 index 2 etc we need to make sure that we increase our counter every single time the loop body is called so go ahead and select counter copy it and paste it and drag from counter and search for plus plus this will give us a node that is called increment end and as you can see it simply adds one to the specified value and then sets it go ahead and select it and connect it to print screen so now every time the loop body is called it'll print the element with the index based on our counter and it'll simply increase our counter by one so control will be 0 1 2 3 etc now we need to deal with our condition to make sure we don't have an infinite loop so let's go ahead and connect our node here and give us ourselves a little bit of space for the condition so let's think about this a little bit we want the while loop to continue printing all our elements as long as we have enough elements in the array so the first thing we'll remember is from our previous lesson there is a way to get the number of items inside our array and that is called the array length so go ahead and select your array copy and paste it and drag and search for length we have the length of our array which we know is 3 by looking at the number of elements here and now we want to make sure that the loop continues to run as long as our counter is less than the number of elements in our array so grab the counter and copy it and drag from counter and simply search for less than select less and now simply connect the length to the other pin let's move the nodes here and connect the boolean to our condition now let's quickly analyze what we're doing here when we first call the while loop it'll analyze the condition here and it'll say is the counter less than the length of our array our contour will be zero and the length of our array is obviously three this will evaluate to true which means that the loop body will execute we'll print element 0 and we will increase our counter by 1.
วิดีโอที่เกี่ยวข้อง
Learn to Code in UE5 - 8 - User-Defined Data Types
23:57
Learn to Code in UE5 - 8 - User-Defined Da...
Coqui Games
16,747 views
Learn to Code in UE5 - 6 - Using Arrays
28:06
Learn to Code in UE5 - 6 - Using Arrays
Coqui Games
27,569 views
Learn to Code in UE5 - 11 - Smooth Movement
36:12
Learn to Code in UE5 - 11 - Smooth Movement
Coqui Games
15,137 views
Learn to Code in UE5 - 9 - Functions and Events
16:53
Learn to Code in UE5 - 9 - Functions and E...
Coqui Games
13,589 views
Learn to Code in UE5 - 15 - Event Dispatchers
18:17
Learn to Code in UE5 - 15 - Event Dispatchers
Coqui Games
6,427 views
I Need to Fix This C++ Project... Otherwise I Fail University
8:27
I Need to Fix This C++ Project... Otherwis...
Zyger
16,444 views
UE Blueprint Fundamentals | Class #5-4 | Nested Loops & Bubble Sort
32:09
UE Blueprint Fundamentals | Class #5-4 | N...
Ask A Dev
4,493 views
Learn to Code in UE5  - 12 - Collisions and Overlaps
28:47
Learn to Code in UE5 - 12 - Collisions an...
Coqui Games
12,750 views
The Single Change That Made Compilers 10x Smarter
5:01
The Single Change That Made Compilers 10x ...
The Coding Gopher
27,266 views
Learn to Code in UE5 - 4 - Using the Event Graph
15:19
Learn to Code in UE5 - 4 - Using the Event...
Coqui Games
29,395 views
The Unreal Engine Game Framework: From int main() to BeginPlay
27:22
The Unreal Engine Game Framework: From int...
Alex Forsythe
222,499 views
Unreal Blueprints Crash Course for Creatives: Learn Classes, Inheritance & Blueprint Relationships!
1:01:04
Unreal Blueprints Crash Course for Creativ...
Ask A Dev
15,746 views
Learn to Code in UE5  - 13 - Direct Actor Communication
36:45
Learn to Code in UE5 - 13 - Direct Actor ...
Coqui Games
11,815 views
5 Tricks you (probably) don't know about Unreal Engine 5
10:44
5 Tricks you (probably) don't know about U...
Cinecom.net
404,358 views
Unreal in 100 Seconds
2:52
Unreal in 100 Seconds
Fireship
935,580 views
Learn to Code in UE5 - 10 - Time-based Code
16:09
Learn to Code in UE5 - 10 - Time-based Code
Coqui Games
10,649 views
UE Blueprint Fundamentals | Class #4 | Branches & Booleans
27:54
UE Blueprint Fundamentals | Class #4 | Bra...
Ask A Dev
7,125 views
Learn to Code in UE5 - 1 - Programming Basics
10:28
Learn to Code in UE5 - 1 - Programming Basics
Coqui Games
65,814 views
How I would learn game dev (If I could start over)
7:50
How I would learn game dev (If I could sta...
Andrzej Gieralt Creative
162,132 views