Unreal Engine 5 (UE5): Blueprints for Beginners | Pixel Helmet | Skillshare
Search

Playback Speed


1.0x


  • 0.5x
  • 0.75x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 1.75x
  • 2x

Unreal Engine 5 (UE5): Blueprints for Beginners

teacher avatar Pixel Helmet, Game Developer & Publisher

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      Introduction

      2:00

    • 2.

      Downloading the Engine

      0:47

    • 3.

      Creating the Project

      1:44

    • 4.

      First Steps in Unreal Engine

      18:41

    • 5.

      What are Blueprints?

      1:51

    • 6.

      Setup & Blueprint Layout

      4:04

    • 7.

      Execution Order

      4:39

    • 8.

      What are Variables?

      1:19

    • 9.

      Integer, Float & Byte

      7:40

    • 10.

      Boolean

      2:46

    • 11.

      Text, String & Name

      7:36

    • 12.

      Vector

      3:11

    • 13.

      Rotator

      2:28

    • 14.

      Transform

      3:08

    • 15.

      Variable Operators

      2:48

    • 16.

      Branches & Conditioning

      4:52

    • 17.

      Get & Set

      4:52

    • 18.

      Variables Example

      10:32

    • 19.

      What are Events, Functions & Macros?

      1:44

    • 20.

      Events

      8:31

    • 21.

      Functions

      9:11

    • 22.

      Macros

      6:10

    • 23.

      Function & Macro Library

      5:03

    • 24.

      Events, Functons & Macros Example

      29:47

    • 25.

      What are Arrays?

      1:59

    • 26.

      Creating an Array

      5:13

    • 27.

      Array Functions

      5:42

    • 28.

      What are Execution Flow Functions?

      1:15

    • 29.

      Is Valid Check

      3:22

    • 30.

      Sequence

      3:11

    • 31.

      Flip Flop

      1:31

    • 32.

      For Loop

      8:24

    • 33.

      While Loop

      4:24

    • 34.

      Do Once & Do N

      5:50

    • 35.

      Gate & Multi Gate

      9:47

    • 36.

      What are Enumerations?

      1:13

    • 37.

      Creating an Enumeration

      4:21

    • 38.

      Compare Enumeration

      2:29

    • 39.

      Switch on Enumeration

      4:15

    • 40.

      Enumeration Example

      19:04

    • 41.

      What are Blueprint Classes?

      1:46

    • 42.

      Actor

      0:52

    • 43.

      Pawn

      1:11

    • 44.

      Character

      0:48

    • 45.

      Player Controller

      1:28

    • 46.

      Game Mode

      1:14

    • 47.

      What are Blueprint Actors?

      0:41

    • 48.

      Creating a Blueprint Actor

      6:30

    • 49.

      Spawn & Destroy Actor

      5:52

    • 50.

      Scene Components

      3:42

    • 51.

      Editable Variable & Expose on Spawn

      7:35

    • 52.

      Overlap Events

      8:53

    • 53.

      Actor Has Tag

      3:04

    • 54.

      Get All Actors

      6:01

    • 55.

      What is Blueprint Communication?

      1:31

    • 56.

      Casting

      8:59

    • 57.

      Blueprint Interface

      17:26

    • 58.

      Event Dispatcher

      16:11

    • 59.

      Game Introduction

      1:09

    • 60.

      Downloading the Project

      4:49

    • 61.

      Game Mode & Player Controller

      3:21

    • 62.

      Creating the Character

      5:11

    • 63.

      Character Movement

      16:34

    • 64.

      Creating the Scroll

      9:33

    • 65.

      Making the Scroll Lootable

      12:05

    • 66.

      Setting up the Platform

      4:26

    • 67.

      Changing Levels

      6:26

    • 68.

      Reward Trophies

      19:07

    • 69.

      Finalizing the Game

      6:38

    • 70.

      What Now?

      0:51

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

1,806

Students

9

Projects

About This Class

Create high-quality games without a single line of code

If you are looking for a fast and powerful visual scripting system that can create any game you want, Unreal Engine Blueprints is your go to programming language. Use the same tools and principles AAA studios use in their Blueprint projects to create high-quality games. Everything is free.

Jump right into game creation with Blueprints

As a beginning developer, programmer, or artist, you might have tried C++ or other high-level languages and given up. They are simply not meant for beginners and you might not need them at all. The beauty about Blueprints is that it allows you to jump right into game creation, and gives you a great entry to game development, but at the same time can be a standalone as the case for many professionals. Designers use Blueprints to showcase their animations, user interfaces, and audio. Programmers and developers use Blueprints to code whole games or prototypes, but can also be used in addition to C++ for more advanced projects.

By the end of this course, you will have learned the fundamentals of Blueprints and coded a small platformer with easy follow-along videos. You will be able to use the same logics in character creation, movement, collision, spawn points, and level changes in your projects. You will also be able to move to more advanced blueprints logics.

My name is Moustafa and I am the director and developer of Farmtale on Steam done only on Blueprints. With many years of experience within game development, I will be here for you every step of the way.

This course covers all you need to know about Blueprints to code your first game, including:

  • Variables

  • Events, functions, and macros

  • Arrays

  • Execution flow

  • Enumeration

  • Blueprint actors, classes, and communication

Learn the best coding practice from a published developer

All code is not equal. There are many ways to develop games, some better for performance than others. Some code might even break. I will show you how to use different optimization tools to achieve game-ready performance.

Join our supportive and sharing community on Discord.

See you in lesson 1!

I wish you the best,

Moustafa Nafei

Meet Your Teacher

Teacher Profile Image

Pixel Helmet

Game Developer & Publisher

Teacher

Pixel Helmet is a video game developer and publisher based in Denmark. We have recently released our first game Farmtale on the Steam platform.

We decided to get on Skillshare to create high-quality courses and share our knowledge with the game development community. Learning can be tedious at times and we aim to create a fun learning experience.

We offer to create courses within Modeling, Texturing, Unreal Engine, Blueprints, C++, Game Design, and much more. If you need any help during a course, please let us know through Skillshare or connect with us on Discord, Twitter, or LinkedIn.

See full profile

Level: Beginner

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: In this course, we are going to learn the basics of blueprints by going through the language together and then create a small game from what we've learned. If you're interested in one of my other courses, you can check out my profile on this website, whether it's blueprints to create your own game without writing a single line of code. Or if you're focused on learning Unreal Engine five in general, you can find a course suited for you. Bombshell that I released on steam is an example of a game only using blueprints. This is especially useful for artists like me to program again from start to finish, even though I do not have a programming background, go ahead and check out my profile to see what courses are released so far, my name is Mustafa, and I am the CEO, game director, and designer of Titan foraged entertainment. I've been working in Unreal Engine for the past six years and have recently released farm tail on steam, which is received very positively. I have also spent 1.5 years developing my personal project, bought Kraft, and currently I am directing, designing, and programming my company's new big title, which is an unannounced 3D platformer. This course contains everything you need to get started with Unreal Engine five, including my personal experience over the many years and projects that I've worked on. At the end of this course, you'll be able to program using blueprints and create your own small game from scratch. This course is divided into sections and we'll cover and Unreal Engine 5, overview and navigation, blueprint fundamentals, variables and arrays, events, functions and macros, enumeration, Blueprint Classes, blueprint actors, Blueprint communication. And at the end, we are going to create a game from what we've learned. I designed this course for anyone who's interested in creating games in Unreal Engine five, or struggles with creating a game that will live up to the current industry standards. I hope you'll enroll and join me in this course. And also remember that I am here all the way throughout the course to help you out. I hope to see you soon. 2. Downloading the Engine: Download Unreal Engine five. You first have to download the Epic Games launcher. And do this, you have to go into Epic Games.com. And from here you can click on this blue button called get Epic Games. When you click it, you'll download the Epic Games launcher, which I've already done. So this is the epic Games launcher. And inside the launcher you want to click the Unreal Engine button. And inside the Unreal Engine button, and you can see different tabs up here. Click on Unreal Engine 5 and click on Download early access. I've already done this. So inside of the library you can see the downloaded engines. And this is Unreal Engine five. So this is what we're going to use for this course. Let's create our first project in the next lesson. 3. Creating the Project: Alright, so let's create a new project inside of the Library tab in Unreal Engine, we launched the engine. When the engine has launched, you can see this tab coming up and it's the Unreal Project Browser. Here you can see all the projects that you have previously made. And if you haven't made any projects previously, obviously it will be empty. And so we want to work inside of the Games tab. There are other tabs for film and video and architecture and so on. But we want to work in games. And what I usually do is I usually start with a blank project because I like creating everything from scratch. So we learn the most. But all of these templates, these can be created from the blank project. But these templates can get you started if you are a fairly new in the engine. For example, if you want to make a first-person shooter game, you have this first-person template or the puzzle and third person and so on. But again, all of these templates can be made from scratch, from the blank project. To the right, we are going to choose blueprint because this is what we're going to use. And this tube is fine, Maximum quality preset. And I want to uncheck the starter content. We don't need any and we're not going to use ray tracing. And this project, you can call it whatever you want. I'm just going to call it blueprints and click Create Project. So and the project is opened up. This is what you will see. So this is Unreal Engine five. And in the next lesson, let's talk about the interface of Unreal Engine 5. Before we go to blueprints. 4. First Steps in Unreal Engine: Even though this is a blueprints course, I want to go a bit about the Unreal Engine and the interface. Because even though you are a programmer, you have to know a bit about the engine and how to work around. Sometimes the client wants you to add a light, or they want you to delete something, they want you to change some properties. And also when you're programming, you have to change some properties and you have to know where in the engine you can find things. So to begin with, we can start to the top left. We have all of these default buttons that you have seen in other software too. In file here we can create a new level, we can open a new project, we can save the current project, we have an edit. The important thing is the editor preferences. So if you want to edit something inside of your editor, here is the preference is for it. I haven't worked too much inside of here, but you can see here that you can, you can edit the editor to your liking. And we have the project settings. Inside of the project settings, you will be working a lot and we will get to it later on too. But inside of here, for example, you can change the game mode that you are working on. We will get to that later. And you can change the movie for when your a game starts up. This is the packaging settings for when you're finished with your game and description and so on. So a lot of said settings that you have to work with when you're making a video game. The next thing is the plugins. In some of the plug-ins, you can see that you can enable and disable a lot of plugins. And the most important thing for me when I start a project is inside of the virtual reality. I usually always disable Oculus VR and disable the steam VR when I create a new project. Because when you put this game on Steam and it's not a VR game, it will open in VR mode for some reason, which it did for farm tail when I released my game on Steam, it at usually opened on VR even though it wasn't a VR game. So I usually just say, well dose and restart the engine. But for now you don't have to do this. So we're not really going to need to disable them, but I just did so you could see it. Okay. And the next thing is window inside of here. You can open multiple windows if you wish to. For example, you can see here we have a details panel inside of Windows details. You can open a second Details panel. And you can see here these are actually the same windows. So if I clicked something inside of the viewport, you can see that this same information is displayed both places. So inside of window you can open multiple windows. And this is very useful if you have multiple screens. So for example, I can pull this to my second screen and I can work there. We don't have more important things inside of Windows for now. Inside of tools, we will skip this for now and sort of build. We will skip this for now. And mHealth, you can read about the documentation of Unreal Engine. The next thing is down here we have a save button. Inside of the create button. Is this important to? Here you can create different assets. For example, lights. If you click on point light, you can see that you have created a point light. I'm going to delete it again by pressing the Delete button on my keyboard. And inside of the Creator you have shapes. You can create a cube, sphere, cylinder, cone plane. You can create cameras, visual effects, volumes. We'll get to that later. And these are all the classes that you can create. The content is you can open a new content browser. And the content browser is actually down here. If you click this button or if you click Control Space, and this will make it pop up too. But if you click on content browsers, this is actually the same as this. So you have multiple windows for that to blueprints. This is actually what we're going to work with mainly. And inside of here you can program the game. We can create a new blueprint class and open the Level Blueprint which will work in later. Don't worry about it for now. And in cinematics we're not going to touch here. You can create cinematics. We have different tools here we have the Select tool, or you can select different things. We have the landscape tool, so you can create a landscape for the game. We have a foliage tool here. You can please foliage such as grass and vegetation plants, so on. We have the mesh painting tool. So if you have a mesh like this one and the ground, you can paint on it if you have a texture, but don't worry about it for now. This is a blueprint scores, not a, an artist course. We have the fracture tool, and this is self-explanatory, and we have the brush editing tool over here. We have the Play button. So if you click play, you can play the game you are currently working on. So this we will use very much. If you click on the three dots beside it, you can open the game in a new editor instead of opening it inside of the viewport. And, and platforms here you can package your game to different, different platforms. And in the settings to the right, you can view the world settings. We'll get to that later. You can view the project settings with which we already did from up here. And you can also view the plug-ins that we already watched two. Okay, so I'll go back to the editing tool here. The next important thing is the Details panel to the right. So in the Details panel, you can see here different properties. So if you click on different things inside of the view port, you can see that different details are displayed. And these are the details for the thing you'll have selected in your viewport. Now if I select my ground mesh, you can see the different properties it has. It has the location where it is, it has the rotation, the scale. So for example, if I change this location, you can click and drag. You can see it changes the location. You can also just type a number. There are many settings such as physics, collision, the lighting rendering, navigation, and so on. Here are all the details for the thing that you select and there's of course a different details for whatever you select. So if I select the lighting, you can see here I can change the intensity of the light. If I select the reflection sphere, I can change the brightness of it, the radius of it, and so on. So this is the Details panel and it's very important we are going to work a lot with this. The cell panel. We have the World Outliner, which you can see here to the right. If you click on the World Outliner, this is actually what you have inside of the level you are currently working in. So for example, we have this ground mesh. If I click on this ground mesh and click on the World Outliner, you can see here that I've selected this floor. And if I click on this one, this is the skylight. And if I click on the word outliner, you can see that I've selected the skylight. You can also select the different items inside of the viewport by clicking over here instead of the items over here. So if you clicked on them, you can see that it's selecting them inside of the viewport. Now these are all the items that you have inside of your level. The world settings here, mainly we are going to change the game mode if we want to do anything in here. And this is for blueprints, don't worry about it for now. So we're not going to work much inside of the world settings for now. The last thing before we go inside of the viewport is the constant drawer. So if you click on this button or if you click control space, you will pop up the content draw. Inside of this content drawer you can see folders and this is where all of your files will be for the game. So if you have a character or a, an enemy and MPC, for example, if you have a model of a coin that you want to use in the game, all of these files are inside of here. And once you have the file inside of here, you can actually drag it inside of your level. So for example, I can have a health potion or a manner potion that I want to display here. I can drag it in inside of my game. So here are all your files. What you can do is you can also create new folders by right-clicking here. Create a new folder. You can right-click the folder, and I'll also choose different colors for it if you like organizing things. So now you can have colors for your folders and you can also add them to favorites if you wish to, for easy access, easily accessing them. So I'm going to delete this new folder by clicking on either right-clicking and delete. Or I'm going to simply click Delete on my keyboard. If you don't want to click control and space all the time to get this content draw or up, you can actually click on the Content drawer and click Dock and layout this whole duck, the Han, the content browser. And actually it appeared up here for some reason. What you can do an oral agent is you can actually click and drag the tabs to move them around. R. For this one, I'm just going to click, right-click and click Restore tab. And you can see here it's actually a tab now. But I want it down here just like the usual Unreal Engine, just like normal engine for. So I'll drag it down and I'll put it down here. And I can downscale it, so I have more space. You can work with this content browser as you wish, instead of clicking on the congenital all the time. And if you don't want this anyway, you can right-click and click on Close and you'll be back to where you started. But for this course to make it easier for you to see it all the time, I'm just going to click Dock and layout and have this appear all the time. Okay, So the last most important thing actually inside of the engine is the viewport. This is very important because here is what you will, this is where you will see your game. To navigate around the inside of the viewport, you have to click, hold, click and hold, right-click on the mouse button. You can see here that you can look around while doing that. While they were holding the right-click, you can click on a, W, D, and S. So here you can move around in the viewport while Leila, you're holding the right mouse button, you can see that you can move the mouse and move around. And it feels fairly awkward if you're not used to it. But if curios to playing games, this feels very natural. Just playing, pressing a, W, D, and S while you're holding the right mouse button, council hold the left mouse button. And you can see that you can move around if you move the mouse. And I usually never use this. I actually never use it. So I usually just hold the right mouse button and move around when I'm working. Can also use the mouse wheel to zoom in and out. Or it can simply just again, just move closer using the holding the right mouse button add moving around. So this is the same thing. It can also move up and down by holding the left mouse button and the right mouse button. And you can see here they can move up and down. And again, I never use this, but this is there if you want to use it. And inside of the viewport we have different buttons. We have this button. And inside of here you can show the FPS. This is very important when you create your game. So you can see that your game is not lagging because it's an optimized. You can actually also view different steps for when you're optimizing your game. We will not get inside of game optimization for now. You can change the field of view. You can also very important click on the game view and what the game view is, you can see it hides all of the icons inside of the view port. And this is pretty good for when you want to see your games without any of these icons in the view. So you can actually make them appear again by clicking on the game view. Or you can press G, This is what I usually do. So if you see my icons appear and disappear, this is because I'm pressing G again and again. The next important thing is the immersive mode. So this will fullscreen the viewport. And this is pretty cool for when you want to see your game fully. So and also access it by pressing f 11. So if 11 will minimize and maximize the viewport and G will make the icons disappear. So now you can view your game without an LD snowing icons in your view. So I'll press G again, and I will press f 11 to get back to the normal view. And the last thing in here I usually do is either create a camera. If you want to create a camera where you are standing right now, you can click on Create camera here and choose what kind of camera you want. You can also take a screenshot of what you're viewing right now. The next thing is you can change between the perspective modes. So for example, you can view the top view of your game. You want to change it to button, bottom to left, right. And this is pretty cool for when you want to place something very specificly. For example, if you want this in the middle, you can click on riots, you can click on left and also make sure it's in the middle and so on. Instead of trying to, to make it go inside of the middle, the perspective mode, then it's a lot easier to use this view modes. We have the lighting modes. So inside of these view modes, we have the lead, what we're currently in. And this views the game with the lighting that we currently have. We can also view the game without any lighting. And so you can see we have different view modes that we can use. Inside of the show. You can display and remove items that you don't want to see. For example, icons here. And to the right. Very important. I'm actually going back to the LED mode. And to the right here, you have different tools you can select. This is the select tool. So this is to select or making us being able to select items inside of the viewport. We have the Move Tool. So here you can see a pivot points appear. And when you drag the pivot points, you move them in these directions respectfully. So you can do that with all of the items inside of that level. If you click on the white ball and the middle, you can move it in all different directions. If you click on the square on either of these axis, you can move it, move it in two different axes. Instead of one, we have the rotate tool. So with the rotate tool, you can rotate the item. So if I click on the ground mesh and I click on here, you can see that it rotates it or the axis I've selected. The next thing is the scale tool. So for the scale tool, you can choose to scale it in different directions. Or you can choose to click on the white square to make it scale uniformly. And what I usually do, and this is very important, is to use the keyboard for these tools. So it takes a long time to click on the Move tool and then move the ground and then you want to rotate it. You click on the rotate tool up here and you rotate it and so on. What's a lot easier to do is click on the queue. If you want to choose the Select tool, click on W. If you want to move, click on e If you want to rotate and click on R if you want to scale. Or Q, W, E, R. So for example, like look WE to move it. I'll click E to rotate it. I click R2, scale it down, maybe this way I can click W to move it again and so on. The next thing is the snapping tools. So the snapping, you can see here, when I move this ground, it's not moving smoothly. This is because we have the snapping turned on. And right now it's snapping every 10 and the grid. So if I make it 50, you can see that it's snapping a lot more in a wider distance. So if and I can disable this snapping by clicking on this icon here, and you can see it turns up white. And this is because it's not enabled anymore. And I can move the ground mesh smoothly. The same thing goes for the rotates. So if I rotate now it rotates every ten degrees. You can change it to another number or you can disable it by clicking on the icon. And now you can, you can rotate it smoothly. And this is the same thing with the rotate or the scale tool. Here you can change the camera speed. This is very important too. So if you want to work with something very close, you want, you don't want to have a very quick camera. So what you want to do is reduce the camera speed. And now we can work with something very close. Or if you have a very huge world, you want to increase the camera speed so it can get around much quicker. And the last thing is these viewports. So if you click on this button, you can see all of the different viewports at the same time. So here we have the perspective view, we have the back view, right view and a top view. And here you can work with the different views instead of only having one at a time. You can also maximize one of the viewports by click on this button here. And you can go back by clicking on the button again and maximize the viewport. Ok, and their final important thing is to save your work. You can simply click File and Save all. But for now, I'm not going to do it because I don't really want to save this level. I just wanted to show you how to use the engine. We will create our own new level in the next lessons. So this was all of the important things inside of the engine. It's alright so that you don't know everything. If you're fairly new to the engine, you'll get to know it step-by-step. But these are all the important step to get you started. So let's go over to the next lesson and learn more about blueprints. 5. What are Blueprints?: All right, so before we start doing any blueprints, I want to explain what blueprints are. So when I say blueprints, you're actually programmer. If you're working with blueprints, it's not the, something else or you're not cheating or whatever. Blueprints are a form of programming. And it's actually a visual programming. So it's called visual scripting. And what you do with the blueprints is actually, you can see here it's very visual. The other programming language, for example, C plus plus that you can choose in Unreal Engine. This is what it looks like and you have probably seen it previously. This probably means nothing to you if you are not a programmer and it looks very confusing. This is why blueprints are so nice. It's a lot easier to use and you can visualize what you're actually doing. So this is a life changer for artists. And some people think blueprints are weak, that you can't create powerful games with it. Ashley, I created my game on Steam fontanelle fully on Blueprints. There's not a single C plus plus code. Also, you can create other games that I have. I've put up a couple of games that you can definitely create blueprints with or without any problems, without any lag or anything else. For example, mario, a platform where you can create definitely with blueprints. It can also create a game such as the forest, which is currently on Steam. You can also create started valley, or you can create Minecraft. You can also create other games such as Counterstrike and so on. So blueprints are very powerful and you can actually create anything you have in mind. Okay, So enough about what blueprints are. Let's actually go inside of the engine and start looking at the interface of the blueprint editor. 6. Setup & Blueprint Layout: Okay, so before we do anything else inside of the engine, I actually want to create a new map. I don't want to work on the one we're prices practiced on previously. So what I'm going to do is click on File and click on new level. And I'm going to choose the default one just so we have a, a level would lighting. I'll click on the default. And now it asks you to save this level over here. I'm actually clicking, don't save because I don't want to save it. Once you have created their new level, you can go ahead and make a new folder down here. And you can call it maps. And what you can do is actually save this level inside of here. So I'm going to click Save All and it gives you nothing happens. This is actually because I haven't done anything in here. So if I just click on something and move it around, I can click on again, save all. Now it asks me to save the level. I'm going to go inside of the maps and I'm going to call it map. And it doesn't matter. I'm just going to call it tutorial. It's always nice to have a naming convention in front of the, the files because when you have a huge game, you want to search for something. It's always easier to just write map and all of your maps will appear. So this is the new level we have created, and I'm going to click Save All. And now we can work inside of this level. I'm going to click on this reflection sphere and click Delete. I'm not really going to need it. Also clicking on the fog, clicking Delete, and now I haven't this level. So to answer the blueprints, we have either the level blueprints or if you have not already seen it, you can right-click down here. And you can see that you can create a blueprint class. Inside of here, there are a lot of different blueprints. So these we will work with later. Don't worry about it for now. Let's make it easy to begin with. We will start up here and the blueprints, and we will open the Level Blueprints. So this is the blueprints editor. You can see that the editor almost looks the same as the default engine interface. We have the Details panel to the right. We have a compiler down here. And we can see the different graphs that we make. Over here. We have something called functions, macros, variable, and even dispatchers are about those for now. Up here you have the other buttons that you also saw here. Material have different buttons. There were about a Fernando. I don't really want you to be confused right from the beginning, but don't worry about it for now. The most important buttons inside of this editor is decompile. So the Compile is when you create a code and you want to clean it out, and then you can play it. You click on compile and play. When you want to find something, you can click on Find and you can search for some blueprint. No, do that you have you can go inside of the class settings and you can change something in their class settings. You have the class defaults that you can change some settings in. And here in the middle, which is very important, is all of the code you're going to write. So here you can zoom in and out using the mouse scroll button. You can also hold the right-click to move around. And just hold right-click, move around and the viewport to move around. Hold the left-click to select all of the code you have written. And this is all about the important things you have to know inside of this editor. And again, all of the files you create, not actually files or the notes you will create will appear here. So for example, if you create a variable that you can use your later on, we will get to that in the later videos. You can see here that the, that the node is actually created over here to the left. But let's delete it for now. We're not really going to need it. So I'm going to click the Delete button, and I'm going to click File and Save all. Let's talk about the execution order. 7. Execution Order: Okay, so let's talk a bit about the execution order. And the execution order is in what order the code will be executed or, or run. So to begin to work, loads go inside of the level blueprints. And inside of here, I'm actually just going to create a print string. So this will print a text on your screen. So you can see here, you can right-click inside of the event graph and you can type whatever node you want to create. You can also find nodes by clicking down here and clicking on any of these nodes. And you can see here it creates it. So what I want to do is click here on the execution pin. This is the execution pin and this is an event. Don't worry about it for now. And this is what will happen when we begin playing the game. And if you drag from the execution pen and just write print, you can see here something called print string, and this will print a text document on the screen. So if you click it and you can move it around. And I just like organizing things. And you can also make it straight by selecting it, holding the left-click, select these two notes and click on Queue. This will straighten both of them if you have many of them. And so this will print a sprint string. So I'll say my first message and press Enter. And you can also click on the arrow down here and you can change some settings. So for example, I want to display it on the screen for 10 seconds and the color should be red or orange or wherever. Okay, I'm going to click on the arrow again just to hide this information. And I want to print another message. So if I click or I hold this execution pen and let it go, I can write print again and click enter and click another print string. You can also simply just copy this by clicking Control C and Control V to copy it and paste. Okay, So for this next one, I'm going to say second message. Okay, so now I have two messages and again, I'm going to display for 10 seconds down here. It's all up to you and maybe this color. Okay, So now we have this code. This is your first code. And to finish the code, we have to compile. So remember to compile, the code will work and remember to save. Or I can click File and Save all. This is up to you and you can click on place. So when I click on play in here, its symbol is a simulating and it, you know, it's playing. So you can't really add code because you're clicking play, you have to click stop to add more code. But when you click play is the same as clicking play up here. So if I click Play can see it's splaying right now. And over here to the light inside of the viewport, to the top-left you can see it says my first message and second message. Okay, if I click up a play again, you can see to the top left it says my first message and second message. So the execution order is that the code will always execute in a chronological order. So it starts with the beginning play, the event, then it goes over to this one, and then it goes over to this one. It can never go from this to this without running this part. Okay? So this is very important to understand. So let me add some more nodes. Actually, you don't have to follow this, but I just wanted to show you. So let's say you have all of this code. And the game is, when you play is going to run this one and then this one, and then this one, and then this one at the end. It's never going to play this, This, and this only it will also play this one and this one. Okay? So this is very important to understand. You cannot jump in code, but you have to run this line of code one after another. So this was it for the execution order. This is very important to understand and you can actually just delete this event tick also if you want to. And remember, always to compile. So this was your first code and blueprints. And actually this is very simple. I just wanted to show you what the execution order is. And remember, it always runs in a line of code. It never jumps in this line. And let's go over to the variables. 8. What are Variables?: Okay, so it's very important to understand variables because this is the main principle in programming. And you're going to use it all the time. And what a variable is a container that contains information. So for example, it can contain how much coins you're a player has. It can contain what type of hair the player has chosen in the character customization window. It can also contain how much health the player has. It can contain information about if the player is dead or not, if the player is alive or if the player is running or not, or how fast the player is running and so on. So it contains all of these different informations. If you want to create a variable over here to the left, you can see the variables tab. You can click on the plus button. And this will create a variable. You can give it a name, and you can choose what type of variable this should be. You can see here if you click on the variable, you also have the Details panel. And here again, you can change the name and you can change different properties for this variable. In the next lessons, I want to go over what all of these variables are. So I want to explain all of these variables and we get an understanding of watch what each variable will do. 9. Integer, Float & Byte: All right, so the first variable types I want to talk about are the integer, float and bite. So to begin with, let's create the variable. I'm actually going to delete these print strings that we used earlier. And let's create a new variable. And the first one I want to talk about is the integer. And let's call this one amount of coins. So you can either right-click and click Rename, or you can simply click on it and click F2 and right amount of coins. So this is the name of the variable. You could also have changed it over here if you wish to, also changing the variable type, if you wish to, you can do it here. And this one, I'm going to drag it out and clicking on Get. Them are about getting and setting. We'll get to that later. But for getting you can also, instead of dragging and clicking on gets, it can hold Control and drag it out and it's all get it automatically. Okay, So the amount of coins you can see here, it says, please compile the blueprint in order to enter the values. So clicking on compile, we'll make this appear. And here we can set the amount of coins that the player has. So for example, 200 coins. And again, this will change dynamically inside of the game, but we are not that advanced right now, so we are changing it manually. So now the player has 200 coins. So if you click on this variable, it says 200. That is what we said. And I actually want to display this number to the screen. So if I drag out and I click Print, you can see there is nothing called print string. And this is because the print string, the considered the node that prints the message on the screen. It's actually a variable to a string variable. So you can see here it's actually a string variable type. So this is not really the same and therefore it can't print it. But actually you can print it if you drag this pin and connected with the string, and it actually says to you, I'm going to convert this integer to a string before I can print it. And this is what it's doing. It's converting the integer to a string and then it connects it to the, to the print string node. You could also have done it on our manually by clicking to string. And you can see here two string, and this is actually the same and you could have connected it to the print string. So the same thing. And if I connect this event to the execution pin. And this is now saying when you begin playing the game, please rent this amount of coins to the screen. So I want to print it for ten seconds, for example, so we can have some time to see it. Click on compile, click on Save. And I'm going to minimize this a bit and click on play. And you can see here it's actually and Jing 200 coins on the screen. So this is what Job's are. This is a number you can choose. And very important to know is integers can't contain decimal numbers. So this is what floats are. So integers is without decimals, okay? So if I create a new variable and I call it for example, weight, well, this could be the character weight. And I'm going to change the type to a float, and I'm going to hold Control and drag it out. So this is the weight variable. And again, I'm going to compile to see the values. And now you can see here this is a number would decimals. Okay? So for example, the weight of my character in kilograms is 75.85.8, for example. And so now this is, this is a number with a decimal, so I can't write decimals here. This is not going to be accepted. So an integer is a number without decimals. A float is a number with decimals. And it can, I can choose to print this on the screen. So if I am connected and you can do this by holding Alt and clicking on the execution pen, either this one or this one. And this whole disconnected, I can move it away. And I can connect this to the string variable, and it will automatically convert the float to a string so it can print it on the screen. Click on Compile, Save, and click on play. And you can now see it displays the weight of my character of 75.8 kilograms. Okay? So this is what floats are. The last thing is the byte. I'll click on Create new variable. And for this one I'm going to chew or I'm going to call it hair type. So this is, for example, the type of hair the player can choose and the character customization screen. And I'm going to change the variable to bite. So I can click hold Control and drag it out. So this is my y-variable. I'm going to compile to add a value to it. And now you can see here, this is also a number. And what a byte is, is also a number without decimals, but this one can only hold up to 255. So 255 is accepted. If I go to 256, this is not accepted. You can see it changes it automatically to 255. So this one can, for example, be used to for hair types. For example, I doubt that the game will have more than 255 types. So for hair types, I would, for example, use the byte instead of a float or an integer. And this is also because you have to prioritize what you want to choose for each scenario in your game. Because byte is using less memory than these two, because it's so small, um, and so you can try to optimize your game doing this. So instead of using a float for everything, instead of using an integer for everything that doesn't have decimals, you can use a byte if you, actually, if your options doesn't have more than 255. So for example, I want to choose hair number 56. And you can see, you can print it on the screen again. I'm going to move this away. Whoops, I'm going to move this away. We can see this one. I'm going to click Compile and play. And you can see here it displays number 56 that we have written inside of the byte variable. Okay, so these are the number of variables I wanted to talk about in this lesson. So we have the byte, which is the number without decimals, but it can only hold up to 255. We have the weights are the float variable which can hold decimal places. And we have the integer which is a number that cannot hold decimal places. So this is good to use for coins, for example, or, or points or whatever, because you don't really need decimals, four points, unless your points inside of your game has decimals than in this case, you want to use a float instead. 10. Boolean: The next variable type is a Boolean. And before we talk about it, actually you can select these three different variables that you create it. And you can click on the CC button on your keyboard. And this will create a comment. And I'll just write variable types. And I'll try to place all of the variables here as we go. So I'll drag this down. Okay, So the next thing is Boolean, and you can click here, create a new variable. And we can make a Boolean called is dead. And for Booleans as good practice, this is done in C plus plus, right, to be in front of Boolean. So we know it's a Boolean. And I'm going to run it like this. So b is dead. And I'm going to change the variable type to Boolean, and I'm going to drag it out and click on Get. You can see here that B is actually not displayed even though we wrote b. So this is a secret thing we can write, and we know it's a Boolean. So what a Boolean is, is a container that contains information which is either true or false. So if we compile, we can see here, you can take this, can either be checked or unchecked. So it can either be true or false. So for example, as your character holding a weapon, it can say, we can make a variable called is holding weapon. And it can either be true or false. So for example, for this one is the character that it can either be yes the character is dead or no, the characters are dead. So this is what a Boolean is. And for example, we can see here if I connect it to a string or to the print string that we had earlier, it will convert it to a string. And if we click on Play, you can see here now it's false. This is because it's unchecked. And if I click escape and go back, and if I take it, compile click Play, it says true. So this is a Boolean. It's either contains information which is either true or false, and we can use it for different scenarios. So for example, is my player holding a weapon because maybe I don't want the player to be able to sprint and the game if he or she is holding a weapon. So I'm checking is the player, is the player holding a weapon? And if so, I don't want the player to be able to sprint. Is the player dead? In this case, then I want to disable all the movement, or I want to restart the game or whatever. So this is what a Boolean is. 11. Text, String & Name: So the next two or three variable types we want to talk about is the x-variable and the string variable and the name variable. So let's go ahead and create a text variable. And for this one I'm going to call it game over message. So this is a message that will be displayed when the player dies, for example. And I'm going to call it changes to a text variable. I'm going to hold Control and drag it out. And you can see here now we have a text variable. We have to click Compile to add a value. And here in the default value, we can add a text. So for example, we can say you died or something like this. So now we have a text and if I connected to the string variable and it converts, it will compile and play. You can say that says you've dyed up here to the left. Okay, so this is a text variable. Now, we can also create a string variable. And for this one, let's call it server name. And we choose string type. We can drag it out. And you can see here now I have a string variable. If I compile, a string is also a line of text and I'll, I'll explain to you in a bit what the differences though we cancel. For example, the server name, let's call it just my name was the first server. So this is my server name that you can see you when you join the game. And let me disconnect this. And I want to drag it down here. And if you connect it, you can see that it's actually not converting anything because this is a string and this is a string also. So it doesn't need to convert anything. So we can just connect it directly and click on compile and play. And you can see here it says most of us server, okay? And now this is a string and the last one before I explain the difference between these two, the last one is a name variable. So for this one, for example, we can call it weapon name. And we can choose the name Here, name, variable type. And let's drag it out again. Click on compile. And you can see here, you can choose a line of text again. So for example, if this is a shooter, I have an AK 47. Okay, click on compile, connected, it will convert it to a string, Compile and Save and click on play. And you can see it says AK 47. Okay, so these are the texts, the variable types, the, the text, the string, and the name. And you can see you can write a line of code for each of them. So what is the difference between these three? You can write a line of code and all of them. What is the difference? The difference is, or for the text variable, this one uses the most memory, and this is the medium, this is the low memory. And for the text variable, this one is localizable. Can see here if I hold the mouse over this text, it says localized texts. And what localization is, you may be already know it, but this is when you translate a line of text in other languages. So for example, if I, if I want my game in English, but I also wanted in German, I also wanted in Chinese or in Japanese. I want to translate this game over message to type Chinese to inside of my game. And this can only be done if you have a text variable, you can't translate the, the, the engine won't be able to translate this string variables. It can only translate the text variables. So when you create a line of text and you want your game in different languages, you have to have in mind, do you want to translate this line you're about to write? And if yes, I want to translate it, then go ahead and make a text variable because you can't translate these others to other languages. And just to show o'clock, we'll quickly, this is not about localization translation material inside of delocalization dashboard. Here you can see here you have the English language and you can add more languages and you can translate to different languages. And this can only be done for text variables, okay? The string variable. You can't translate this. This cannot be translated like the text variable, but you can write a line of code and this can be used for things that is not going to be translated. So if you're a name or if your game is never going to be translated, you can also just use a string to write this game over message. You don't have to use a text if you don't want translation. So this is also a line of text and this is not going to be able to be translated. And for example, a server name. If you're playing online, you don't really want to translate my server name to other languages, so it doesn't really make any sense. So for observer name, I would be using the string variable. And the last one is the name and foreign name. This one cannot be translated. And also a good thing to know, these two variables can be manipulated. This cannot be manipulated. And when I meet my, what I mean by this is, for example, if you drag out from the string and you click on append, we can actually add more text to your text over here. So for example, if I write inside of the append, must ever server, it says most of us over here. For example, if I write number 1, if I connected this pin to the print string, just so I can print it and I can show you, I click Play. Now it says Most of us server number one. So the texts variable and the string variable can be manipulated during the game. This one cannot be manipulated and this will be unique. It will only be called 1847. And you don't really have something that can add stuff to it. So this is, this is the one that uses a less memory than these two, and only using these four unique things. For example, My name of the weapon is always going to stay the same, so I'm never going to change it. It's always going to be called AK 47. So for the weapon names, I would use this variable. Also, for example, you can use it if you have achievements in your game and you want an idea to these achievements. So for example, if your ID is a CH, for example, for achievement 07, this is never going to change. I would use achievement IDs and I would use a name variable for this. So this, these are the texts variables. You can write text and all of them, but these are the main differences for these variables. 12. Vector: Let's go ahead and create a vector variable. So click on create new variable. And for this vector variable, we're going to call it cam location. So for example, if we want to specify the camera's location inside of the world. So changing the variable type two vector and let's hold Control and drag it out like on compiled to see the default values. And you can see that the vector contains three numbers. So here, if I minimize this a bit and go over here. If you click on the mesh inside of the world and see you that the vector contains this information and this is, the vector is typically used for locations. So for example, we can modify the location of the ground, which are the three or number three numbers. So for example, a fatwa, one hundred, one hundred, one hundred. This could be the new location for the ground so that we can modify it through code. If I click on Compile and Save. And you can also drag it out here and print it out. And you can see if I click a clay, it renders out the x, y, and z axis, which we set to 104 for all three of them. So just to show you quickly, for example, if we click on the ground mesh and then we'll right-click inside of our level blueprint. We can create a reference to the floor, which is here. And you can drag it out and you can search for the location or it can actually just right location. And you can see here these are the different nodes that you can edit. And we want to set the actor location. And if I disconnected this print string, and I connect this set actor location. And if I connect this new location, so now instead of CAM location, we can call it Laura location. This would be more appropriate and we can connect it to the new location. So now, when we start the game, we are going to set this floor location to this new location. So instead of being 000 20, it is going to be one hundred, one hundred and one hundred. So if we compile, we have to remember to set it to movable so we can change it in the game and click on play. And you can see here that actually it's maybe it's better to put a delay because now you can't always see that it changed the location. If I just drag her out here and ride delay, this will delay the code or an amount of time, for example, three seconds. And then it will play this set actor location. Okay, so if I click Play, you can see here after three seconds. Actually let me minimize this so we can see something like on play. And after three seconds, it's going to change the location as you see here. Okay, so this is what we can use vectors for. 13. Rotator: A rotisserie variable is used to change the rotation of an item. So let's go ahead and create a new variable. And let's call it law for rotation. And for this one we're going to change the variable type to rotator, and we're going to hold Control and drag it out. And for this example, let's compile first. And you can see here these contain three numbers, and this is actually the rotation. So if we click on anything, for example, the floor, we can change the rotation. So these are the three values. And if we want to edit them dynamically inside the game through this variable, we can click on the floor, Right-click here in the graph and click Create floor reference, just like in the previous lesson. And let's drag out and type rotation. And you can see here that you can set the actor rotation. So let's connect it to the Begin Play. And for this, let's connect the new rotation. And right now it's set to 000, so nothing will happen. But let's say for example, the x-axis we want to rotate 20, the y-axis we want to rotate AT, and the z we want to rotate 30. Okay? And let's put a delay so we can see the difference from before and after. Though. When we begin playing the game, after three seconds, rotate the floor mesh. Okay, so let's try to organize it a bit. It's always nice to organize it. And remember you can use C to comments. So for example, if you want to see you on all of them and click, All right, for example, floor rotation. Now this is good practice. If you have a lot of code, it's always nice to to have these things down. So I can click on the common too. If you want to change the color of the comment, you're welcome to do that. So, and if you want to go this bubble on Zoom or not. And if you want to, for example, show the color up here and all of this. So this is nice for organization. Let's go ahead and click Play. So after three seconds, this floral mesh will rotate, advocacy it rotated. So this is what a rotator is. You can use it to rotate, rotate meshes. 14. Transform: So the last variable type I want to talk about for now is the transform variable type. So if we want to click or create a new variable, click on this plus button, and let's call this one floor transform. So let's change the variable type to transform and let's compile. It can see her if you click on the arrow and the transform is all of these different numbers. So we can change the location, the rotation, and scale of an item. So anything that has location, rotation and scale inside of your level, we can modify it with this. So for press G, just to view all of the icons, we can actually modify, for example, the Sun's location, rotation, and scale through this transform variable. The same goes with the skylight, the same goes with the player start instance. And the same goes for the floor. So for example, let's do it on the floor. We can change all three numbers at once. So for example, my location should be a 100, 100, 100. My rotation shouldn't be 2050, 2080. It's just random numbers actually, and I'll just scale it. Let's scale it down to 0.50.50.5. Ok, and let's drag out the transform and let's compile and save. Okay, so here we can change the Florida transformation. So if I click on the floor, and if I open my viewer right-click and create a reference to the floor, I'll drag it out and you can write transform. So as you can see, the easiest way to search for things if you're new to the engine or new to blueprints, you can just write what you want to do with this floor. For example, if you want to rotate it, you can write rotation is here. You can get the actual rotation. You can set the rotation. If you want to get the location, you can just write location and you can see here said actor location. So this is a good way to search for things if you don't know what they're called, won a 100 percent. So for exam for the transformation, Let's writes transform. And you can see here that you can set the actor transformation. So let's connect it and let's connect the floor transformation inside of new transform. Compile. And let's click play before the playlists actually delayed for three seconds. So you can see there's a difference from before and after. So when we begin play, wait three seconds, then launch at this code. Okay, So let me organize this a bit and compile, and let's click Place. You can see are after three seconds, it will change their transformation of this mesh. So this is the transform variable and it's very handy. And it can also be used on cameras because cameras are also these transformation values. So this is a great variable to use to change the transformations of items. 15. Variable Operators: All right, It's time to talk about the variable operators. So these are the four variables operators that we have. And what an operator is, is we can do addition, subtraction, multiplication, and division. So for example, let's use the amount of coins variable that we have this as the integer variable. So I'm just going to let this be here. So I'm going to drag a new one here. And so we can use it in the code. And for example, the amount of code we can drag the pin out. And to find the variable operators, you can either write plus 2, find the addition, or write minus 2, subtract rights division to divide and write their star for multiplication. So for example of r, r plus and I click on this. Now we can add a number. For example, here we said the amount of coins to 200. And we can add a, for example, let's say 100, so it gets to 300. And we can actually print it out on the screen, screen through the print string connected. And we can compile and click on Play. You can see here that it's displaying 300. Okay, So this is how we use operators and you can actually use multiple. So for example, we can say 200 plus 100 and this is 300. Then we want to divide it by three. So now it will become 100. And we can connect it and click on compile and play. And you can see here it says 100. And if case you missed it, we can just make this time longer, compile and play. And you can see it says 100 year to the top left. So these are operators. You can use them to plus, minus, multiply and divide. And it can make as many as you want to. This can of course be used for the number of variables. So for example, if we wanted to use a float instead, or we want to use a byte instead. So let's use the float. You can see if I drag the float, I can say divide by 5. You can see here they have different colors and this is because this color is for integers, this light green color is for floats and so on. So you can see the different colors or you can see the different variable types through the colors. And again, this will display the result number if I connect this to the string. And so now it's going to display this load to the string, our ear to the print string by compiling. And you can see here it's 15.16 because it's dividing the 75, 0.85. 16. Branches & Conditioning: The next thing is the branches and conditioning. And these conditioning conditioners are actually also variable operators, but these will kill a condition and we'll talk about that now. So this is the branch node and what a branch node is, you give it a condition. And then if it's true, it will do this code. If it's false, it will do this code. Okay, so let's try to use it to easily access the branch. Just simply click hold B and click on the graph. So hold beak, look on the graph. This will create a branch, a branch node. Or you can right-click and write B. And you can see here branch, you can select it. So this is the branch node, and we can give it here a Boolean. You can see the red one is a Boolean, so something is true or false. If it's true, it will do this code. If it's false, it will do this. So for example, let's try to take the amount of coins. Let's drag it out. Let's say plus 50 or what's your ad? And was do 15. Okay? And let's say, let's use one of these conditioners. So for example, we can use is greater. Is this number is in this result number greater than, let's say 300. And we can connect it to the branch. So let's before we continue, let's see what's happening. So we have the amount of coins and we have set it to 200. We are now adding 50 to the 200 coins we have. So now the result is to 250. So the 250 we're asking is 250, is this number greater than this number is 250 greater than 300? Is this true? Now, obviously this is false because 250 is not greater than 300. So this is going to be false and it's going to play this code. So for example, as disconnected by clinking Alt and under execution pen. And let me connect this here and I'll create another print string. And for example, this right here, this is true. Or let's try it. Let's write this is false. Okay, so now it will play the false godless. And remember to connect the branch over here. Okay? I'm going to organize things a little bit. Okay. So it's going to ask, is, is 200, 200 plus 50, this is 250, is this greater than 300? Obviously it's not, then it's going to say this is false. Okay, so let's play the game and see what it's saying. And actually I want to make it 10 seconds just so we can have a chance to view it. Just like this. Okay, and let's go play. And you can see here it says this is false because 250 is not greater than 300. However, if we, let's say, if we said before nine, so is 250 greater than 2, 4, 9, is that true? And this is true. Okay, So this is how conditioning work and you can see you can use all of these. So for example, this is not equal. We can use this. So over here I wanted to delete this one. And so we can arise not equal, and we can get this operator. And for example, we can write a number was right, 600 and connected. And now we're saying to a 100 plus 50, it's 250. This result which is 250, if it, is it not equal to 600? And now it's true, yes, it's not equal to 600. Then it's going to play this message. Now let's compile, save and click Play. And you can see here it says this is true, it's not 600. So for example, if we're at 250, now it's saying 250, is it not equal to this number which is 250? And now it's false because it is equal to 250. So if we click Play, you can see now it says this is false. So this is how you use conditioners and branches. This is very important because you use it in almost every code or actually use it Yan almost everything. So very important to understand this concept. And these are actually also called variable operators, but these have conditions, and this is why they're also called conditioners. And so they have a condition which returns either true or false. And we can launch a code from there. 17. Get & Set: Okay, so now we want to talk about setting the variables. So, so far we have got the variable. So if you drag a variable, you can choose either to get the variable or to set the variable. So, so far we have clicked on get the variable and now we have used it like this. But you can also set the variable. So if you drag it and click on Set, again, set it to a specific number during the code. And you can do the same with all the other things you can see here that I've listed or dragged out all of them inside of here. And you can see, you can set all of the variables. You can either drag them out and click on Set, or you can hold Alt and drag them out and place it. We'll set it automatically. So holding control and putting it inside of the graph will get it holding Alt and put it in, put, putting it on the Event Graph, Full Set it. Okay, so let's try to use it. Would the weight. So I will hold Alt and drag out the weight. And let's see here the amount of coins we have said is 200. So I'll say the greater sign and is, is 200. Or as the amount of coins greater than 300. And let's make a branch. And let's connect that one. So if the amount of coins is greater than 300, we can set the weight, for example, of the backpack that the player is holding. We can set it to, let's say, 20 kilo grams. If we can copy paste it. If it's less than 300 or if it's not greater than 300, we can set the way to 10, for example. So this is how you set the variables instead of just going inside of here and setting it to a specific number, you can actually set it inside of the code depending on what's happening. So we can do it with everything. Let's compile. And let's see here, Let's Want to play and see the value. But right now we can't see the value because we're not printing a string. So I'm going to print a string and I'm going to connect it. And so it's displayed on the screen and we can see what's happening. I'm going to do the same down here. And let's click Compile. I'm going to increase the time to 10, so we have a chance to see the message. Ok, and let's click on compile and play. And you can see here now it's, the weight is 10 because because 200 is not greater than 300. Okay, So this is false, it's not greater. If I said this way to see 100. So is the amount of coins greater than 100 years, that is true. Then the weight will be 20. And now if we hit Play, you can see the weight is 20. So this is how you set variables and example of uses. For example, if the player health is 0, we can, we can set the variable is that to be true if the player is dead, that is, their health is 0. Or if the health is not 0, we can set it to not dead there. Same goes with the amount of coins. We can set it, for example, the player, the player walks into a coin. So we can set the amount of coins to the amount that you get for picking up that coin. Or you can, for example, use plus plus to make it add. You can also write plus plus. This will add it one time. So we can see here it says add 1 to the specified value, then set it. So this is actually setting. If we want to use this one instead, we can plus, plus it would one. For example, if you walk into the coin, you get plus one. And this new value. Let me delete here to not confuse you too much. So if you, if you walk into a coin, you can take the amount of coins were just to 100 and plus it with one. No, now you have 201 coins, but you have to set it to this value to the new amount. So now the new amount is actually 201. So if we try to print out this message or this amount of coins, you will see that the amount of coins is now two hundred and one. Hundred and one. Okay? So this is what centers are for these other ones. These are getters. So you get the amount and the cellulose you said the amount during the game. 18. Variables Example: Okay, so now let's go ahead and take a look at an example of how we can use what we've learned so far with variables. So let's say that player a goes over and loot a coin and you want to check if there is. Firstly, if the player has a backpack to loop decline. And secondly, if there is space enough in this backpack to load the coins that the player is looting. And then when the player has loaded them, the backpack, you will display a message to the screen. So to do this, we want to firstly check if the player has a backpack. So to do this, we create a Boolean because a Boolean returns a value of true or false. Create a Boolean called has backpack. And we hold Control and drag it out. Now, now we have this and drag out this pen and click B to make a branch. Now we have a branch. Okay? So before we do anything, you firstly check when you begin the game, does the player has a backpack? And if you compile right now it's false, no, the player does not have a backpack. This is the default value. And let's see if the player does not have a backpack, we want to display a message that you can't look the coin, but you need a backpack first. And let's make a new variable. And let's call it, we can just call it notice message. And let's make it a text variable. And this notice med surge, we want to set it, so hold Alt and drag it out. And here we can set the message and I'm going to set it to, you don't have a backpack here. Okay? And we can connect it, and let's print it to the screen so we can actually see it when we click play on the game. And let's make it to 10 seconds. It would change that color. And that's connected to the print string node. Okay, so now currently the player does not have a backpack, so it will return. So it says, Do you have a backpack? No, I don't. Then you don't have a backpack. This is the message that will be displayed. But let's say this is true. The player does have a backpack. So now it will play this code instead. And if the player has a backpack, then add the alluded coins. Okay, So lead, That's good. The amount of coins. Let's see the player when walked two over five coins. So we'll say plus and five. So the player has 200 coins to begin with. And now the player alluded five. So now it's at 205 coins. So let's take this plasmid with five and let's set the new amount of coins. You hold Alt and drag it out. Let's set the new amount of coins to a 105 now. And let's actually connected here. Usually I set it like this, just use the space so the code doesn't get too long. And so now it says the amount of coins plus five, it's 205. Now we said the new amount of coins. So now this variable is 205 is not 200 anymore as displayed here. Okay, so now we have 205 coins. Next thing is, we want to ask if there's space in the backpack before we add it or before we put it inside of the backpack. So now I am going to make a new variable. And thankfully we don't need to make a new variable. We can just say, is this. Let's say we have two backpacks, so create a new variable, and this is an integer. And we can call it number of backpacks. Let's say we have two backpacks. So we can compile and said there's value to two. Okay? And now we have this number of backpacks and we also have this amount of coins. So this amount of coins, let's say we divide the coins equally in these two backpacks. So I'm going to divide the amount of coins with the amount of backpacks. So now we have 205 coins and it's divided between these two backpacks. Okay? And now let's say if this number, is it greater than, let's say 200, is there 200 coins in each backpack? Then it's full. If we have 200 coins in each bag, bag, then it's full. Okay. So now we're going to ask it, is this true or not? Let's connect this one. Okay? And okay, so now we have this code. Let's try to run it through to not get confused. So we begin the game. It's asks if the player has a backpack or not. In this case, we have ticketed. So it's true the player has a backpack. We'll play this code. And here you're adding the five, eroding the five coins to the amount of coins. So now instead of having 200 coins in this variable, you now have 205. So now you are asking is the number of coins which is now 205. And this one, you are dividing it with the number of backpacks. So now you have, you have around 102 in each backpack. And now you're asking, do you have 200 coins in each bag back, obviously don't you only have around to 102 in each backpack. So no, you don't have you don't have this amount of coins so you can actually load it. Okay? So now I want to send this message by not the game over, sorry, the notes as message. So if I hold Alt and drag it out and say, you have enough space or so, this is false. And to not get confused because I think when you read the code, it's better to say true, like yes, you have space. It gets confusing sometimes. So here I'm actually going to write not. And this is used for booleans. So, so what it says is, if you divide the amount of coins, which is 205 right now, with the amount of number of backpacks, which is now 102. If this is not greater than 200, yes, this is not a greater than you have enough space. This is actually a lot easier to read than the, than if we didn't have this not not component. So is it, is this number greater than 200? But now we're saying, if this number is not greater than 200 years, this is true. We don't have 200 yet. Then you have enough space. And if it's false, you don't have space. Then you say you don't have enough space. Okay? And we want to print this out to the screen. So I'm going to write when string. And we can actually just copy this one over here and paste it two times. And you will save time by copy-pasting code. And you can print it out to the screen. Okay, So just like this, and now this could be the example. So right now we have a backpack. We actually have space because we don't have 200 coins in each backpack. So this should play this part of the code to fix quick save, compile, save, Save All, and click on play. It says you have enough space. Okay? And if we didn't have a backpack, if I unsecured. Now if we click play, it says you don't have a bag back yet. Okay, So if I have a backpack, but I actually only have space for 100 coins in each backpack. Remember we have 102 coins in each backpack. So for click Play, it says, you don't have enough space. Okay? So this is how you use variables. You can, you can get the amounts. You can place it with a number. For example, you can set the new amount to the specific number you have. You can set messages for depending on what the events are. And you can print that to the screen, of course. And remember to organize the code. And you can actually also comment on the code. So for example, this, you can come and done it and write no backpack. For example. You can come in this part of the code and says, for example, this part of the code. If I, for example, drag it over here. And I commented and says, Checks, backpack is full. Okay? And this is actually very convenient for other programmers. So if you have another programmer or in the future six months later, you want to look back at your code. It's so much easier to see the comments on your code. And because after six months you've probably forgot what you did here. And it's very easy to just go in and read the comment. All right, I hope it's not confusing and if you need any help with it, if something is confusing for you, you can always write a comment to me and I'll answer or you can write in the Discord server and I'll answer as well. Can also look at the social media for typing forged entertainment on Facebook or Twitter or Instagram. And I will also answer there. Thank you for watching and let's go over to the next lesson. 20. Events: Okay, so let's talk about events. I've deleted everything in the graph and to make the event and the begin play we've used so far, you can just try it. Begin play. What you can do also, if you want to find the events, you can right-click and write events. And you can see here that you have all of these different events that you can add. And they have this small arrow to the side. Okay? So right now we have used the beginning play. And if you click it, an event is created. The events are red in color. So if you see something that is already in color, this is an event. Okay, so events is, events are needed to drive code. So without events you can't really drive any code. So for example, the classical anion we've used, if we change the location of the Florida that we have. And don't worry, I'll be using more advanced, advanced examples later on. I just want to explain the fundamentals too. So if we change the location of the floor and we add this, this vector variable that we made earlier. So now we have a function and it's connected to the event. And maybe we want to print a message later on after we change the location and we say, nice, we changed the floor location. Okay? So if this event is not here, if it's disconnected, and by the way, you can disconnect by holding Alt and clicking on the execution pin. So now it's disconnected. And if, if no, if no event is connected, This will never run. So now if I click Play, nothing will really happen because nothing is, you're not telling the game what to do when it begins playing the game. So you have to connect it to an event for it to play. And this, this is for everything, okay? You have to have an event or something to happen. Now there are other events. So the next one is the event tick. And the event tick is a bit dangerous. But it is there and the events AIC is called every single frame. So it will run your code 60 times a second. And this is very dangerous because it will destroy the optimization of your game if you're not careful. So it will make your game leg if you're not careful, careful and if you use it all the time. And what I will say is try to never use this unless you're really, really, really have to. So try not to use it. Try not to use it. Only do it if you have to. But I will show you what happens if I print a string and output play. You can see here it's actually playing 60 times a second. Okay? So this is what an, what the event tick is. And let's go to the next ones. For example, we have the the actor begin overlap and we have the and if your end overlap. So this is what happens when you begin overlapping. And you can see this is with the floor right now because I have selected the floor in the viewport. And if I right-click, I can actually see here at event for floor. If you click it and you can choose these different events, for example, collision, you can find these begin overlap and overlap over here. So what happens when you begin overlapping with the floor? What happens when you end overlapping with your floor? So these are events, These are also red. The next thing I want to talk about a very important and you will, you'll be using this all the time, is creating your custom events. So if you right-click and write custom, you can see here that you can click add custom event. If you click that, you can give the vendor name. For example, I will call it at coins. So maybe we want to use this event for when the player walks over a coin. We want to add coins to this variable called amount of coins, which is an integer that we made earlier. So what I'll do is drag this out while holding Control, I will let go. So it's getting this variable and this one is set to 200 coins right now as a default value. So what I will do is, for example, let's pretend the player walks over a coin and this will give him five coins. So writing plus to add, and I will add five coins. And now we have to set the new amount to this variable. So if you hold Alt gout and put it down so it sets the variable. Now you can connect this new amount to set the variable. So now it's actually 205 instead of 200. Okay, so now you have added coins. And let's delete this for now. Okay, so if you click Play now remember, this is the begin play event. This is what will happen when you begin playing the game. And right now, nothing is happening because you haven't really told your game one to play this. This is not being run anywhere. Okay, so to run this code, you have to call it somewhere. So this is, this is called calling the event. So you have to call it. And to call it, you can just write the name of the event. So now I am calling it in the beginning play, I'm telling the game, when you start playing the game, please go over to this event and run the code. So add at coins, it will go down to add coins. And it will run this event. It will add five coins to my variable and then set it. Okay, so I can click Play and you can see nothing is displayed what it's actually working. But this is because we're not printing it to the screen, we can't see anything. So just, just to see that it's actually working. Let's try to write string and let's connect them. And now let's compile, save and play. And you can see here it says 205 instead of 200. So this code is actually working now. So remember, you have to call the event for it to work. This is always working because this is the standard event. It will always run when you play, begin playing the game. And when he played began playing the game, we told the computer or the game that you should go over to this event and run the code. And we can do this as many times as we want. Maybe I want to make another custom event and I will call it coins message. And with this event I actually want to print out this message. So I don't want to print out anything up here because I only want to add coins up here. But down here I want to print a message and I want to print the amount that I loaded. So to do this, take the amount of coins again and you can hold it and connected to the string. So now what you're going to see is now we begin playing the game. You are telling the game to go over to Add coins, like you're calling this event. You are adding coins to this variable and setting it. But now you have to call this event 2 because the game doesn't really know when to play this IP and you haven't told it anywhere went to run. So to do this, most logically, it's after this when you add the coins, I want to play a message. I will call this event points message. This is the event. So now after adding the coins, it will go down to this, for this event, and it will print a string. Okay, So let's put them up here together a bit. And let's compile save. And now we can click Play. And you can see that it says 205. So this flow is working. It's going all the way down here. Now this is how you make custom events and this will be used all the time. And remember to call the event else nothing will happen. 21. Functions: Now that we have a better understanding of events, Let's talk more about functions. So, so far we have used a few functions. For example, the print string. This is a function we have called a reference to our floor. And here we write, for example, that actor location and this one is a function. Two functions are the ones that are connected to events. And these functions are the ones that do some sort of a behavior inside of your game. Now for example, you are printing a string to the screen or you are changing the location of the Florida that you have. So you can see that these are functions might be F up here. It says F, This is a function. And these functions can be found if you right-click and you can see here all of these drop-downs, you can drop one of them down and see that there are a lot of functions in here. Okay? So you can see some of the functions are blue and some of their functions are green. So there's a slight difference between these functions. Okay? So for example, let's take our classic one, the set actual location. So we can actually get a green one of it. And I will show you what that is. So phi right location. And I scroll down. You can see that I can actually choose this, get actual location, this is green, or I can choose Set actor location, which is blue. And the green ones are the ones that get information, that blue ones are the ones that set information. So what that means is if you click on the green one, this is actually getting the location of the flora. So right now I am getting the location of the floor where it is currently in the world. While as the blue ones are the ones that set the location. So if we want to change the location of the floor, I'm going to use the blue one. We want to set the location to a new location. But if I simply want the location of the floor in the world, I will choose this green one and get accurate location. So the green functions are the ones that get information and the blue ones are the ones that set information. Functions also have inputs and return values. So these are the inputs and these are the return values. So for example, for this input, you can see we have dislocation and we can always make a vector, a vector variable, and we can drag it out and connected to this input. So now this new location that the floor will get is this variable that we set over here. So these are inputs and this is what functions have. They can also have return values. So for example, here, I get the floor location and when I give the location, so now this is the floor location. Now I can do stuff with it. So this is the return value. It's returning the value of the floor where it currently is, where the location currently is. And for example, this can also be done with the rotation. So we can get the actual rotation. And now I can do something with this current rotation of the floor. Okay, The last thing I want to show you four functions that you can actually make your own functions of. Let's go back over here. And let's say we want to make our own function here. So what you can do is actually, you can mark all of the oil, all of the nodes you want to include in the function. And you can right-click and click on collapse to function. So now you have made your own function and you can call it, I'll give it a name, give it something logical that you will remember attendance ten days later. So for example, set floor location. This is what it's doing. So now we have a new function and this is called Set floor location and the one we made. Now if you double-click gets, you enter the function and you can see what it's actually doing. So now it collapsed the R code into a new function. And this is a very great way to clean the code. So remember, when you're creating a game, your code can be Pilbara super long. And you don't really want it to be this long. Remember to collapse things to functions. This is how you clean code. So for example, this one, if you wanted, if you want to change the location of something and the code is very long, you can just collapse it to a function and call it set floor location, for example. Now you can access these functions. You made yourself to the left. Over here. Inside of the functions tab, you can see the set floor location and you can double-click it to access it, as well as double-clicking it here in the Event Graph. Now to use these functions multiple times, you can just, and let me just delete this one and show you. You can just drag it out and place it and you can connect it. So now I can use this function. And this is pretty cool because you can use it in multiple events. So let's say I created another, another event and I call it floor location. Floor the location. This is actually something I already called the variable over here. So let me call the locations just for now. And let me compile and save. And let me, let's say we want to use this again. So I can actually drag this function out and connected down here. So this is easy accessible. This is pretty cool. Instead of just going in copy pasting this code multiple times, I can just make a function and I can use it multiple times. Now, I will show you later on how we can use this in a more practical way. Like if we're making a game and how it's going to be used. But before we end this video, I want to talk about these, these inputs and also when we have returned nodes. So for example, this function over here, you can see it has a lot of inputs and it has a couple of return nodes that we can use. And this, this is, this is something we can add to our function if you want to. So now we have, we have this node, the start node, and we can also make an endnote, and this is called a return node. Now if I make a written note just like this, this is actually the same as if there is nothing. So sometimes or most of the times I actually do this because it just looks cleaner to have a return node. It doesn't really mean anything to have it without anything. But it's just, it just cleans up the code. But if you want any outputs like return values and inputs, you can do this by clicking on the returned node or the starting node. And you can add variables over here. So what you can do here is if you click on the Plus, it will add a variable, just like if you added variables over here, you can add variables to functions. So now I add a variable and let's say I want to return this floor location value over here. So I create a new variable. I call it lower location, for example. There's something that makes sense and I can choose the variable type. And in this case this is a vector. So I'm going to choose vector which is, which it is already there. So I'm going to connect my floor location that the returned node. And now if I compile and save and go back to my event graph, you can see here now we have a return node. Now we can use this floor location out here and do stuff with it. Okay? So this is a protocol that is how you use the add variables to functions and make return nodes. And the same thing. If you want an input, you can add inputs over here, variables two. And let's say for example, the input should be some sort of a text. And the text should be called message. Just something random. I just want to show you. And you can see here now we actually have an input message and we can say, Yay, you change the location. And this doesn't really make sense for now. I just want to show you how to make inputs and return nodes. So this is how you do it. You can add variables to functions. And don't worry if it's too complicated right now. You don't really have to remember this for now. In the later lessons, we will go more in depth about this. I just want to show you how you can make or how you can add variables to functions. Okay, I think it's a good place to stop the video before it gets too complicated. So in the next lesson, let's talk more about macros. And very, very soon, Let's do a practical example where we actually do something inside of this level and we put together all of the things we have learned. So let's go over and learn more about macros. 22. Macros: Okay, so the last thing I want to talk about is Macros. And what macros is, is almost the same as functions, but they can contain delayed or timed function. So what I mean by this, Let's create something. So for example, in the beginning play, let's print a string to the screen and it's just saying hello. And let's delay this code by two seconds, or 2.220. And let's print another screen string saying, hello. Again. This is very creative. Okay, so now we have this code. And now if I try to mark these and right-click and collapse to function just like we learned in the previous lesson. Now it will say collapsing to function failed. And why is this? Let's click on the show message log. And it's going to say delay cannot be placed in function graph. So very important to know, functions cannot contain delayed or are timed functions, that's what they're called. They cannot contain timed functions, so you can't really call Labs it to a function. This will not work. You can collapse this to a function and this to our function. But you can't really collapsed this delay inside of a function. So instead of doing a function, you would do a macro instead. So right-clicking it and Collapse to Macro. Now, now you have a macro and you can give it a name, for example, just message, whatever. So now you have a macro and you can see here it actually contains a delayed function or a time to function. And this is what you want to do. If you have any time functions, you can't create functions. You can create macros. If you double-click it, just like before, would be functions. You can see here you can enter it and you can view the macro. You can see we have an input and an output, just like we had with the function. So if I double-click the function again so we can view it. We have the input here and the output, which is the returned node. And the same thing we have with the macro, but now we can actually have a timed function inside of it. We go back to the Event Graph. You can see that we don't really have an execution pin here, just like we have here. So we can't really continue our code. And this is because you have to add one. And inside of the macro that we have, you have this output. And this output. You can add a variable just like you did with the function. And here you can add an execution pin. So this is something you couldn't do with functions. You can't really add execution pins. What you can do it with macros. So you can connected, compile and you can see here now we have an execution pen and we can just continue our code if we want to code more in our game here in this event. So now you can see here, this is the name of it, so give it something that makes sense. For example, let's say, let's just call it return. And you can see here it changes name. And a cool thing about macros to, apart from the timed functions is you can create multiple execution pins. If I click these three, Let's call it when. Let's call it loose. And now you have multiple, multiple execution pins, which you can use here in your graph. So this is, this is pretty cool and these have uses two. So if you want multiple events to happen here, you can make a macro and do so. You can do it with functions. Functions always have one pin only, but macros can have multiple pins and they can have timed function, our time, the functions. What I usually do when I program is I never create macros unless I really need multiple execution pins. Or if I have, in this case a delay at time function that I need to collapse and I can collapse it because you can't collapse delayed function or time functions to a function, I will collapse it to a macro instead. We also have already pre-made macros. And this is, for example, the is valid by right is valid. And let's see how we can find it. If we scroll down, you can see this one. This one is actually a macro to, they'll maybe, you have seen it before, maybe not. This is a macro and this is actually used, we're going to use that later. But this is used for to see if our object is valid or not. So for example, if we create a reference to this floor, we can connect it. And now the game checks. Is this floor valid before I continue the code? Because if the Florida does not exist, why should I continue the code? So this is actually a macro. And if you double-click it, you can see here that it's actually a macro and there is some logic inside of it. Okay, Let's go back to our graph. And to see your macros, you can see them here to the left and the Macros tab, this is the one we have created. And it can create multiple macros either again by collapsing it to our macro, or you can make a new macro by clicking on the plus and you can give it a name. I'm just going to call it name. And you can put your logic inside of here. And again, you can create variables, for example, execution pencil if you need them. You can also create other variables, for example, booleans and so on. All right, so this was it for macros, and I hope this wasn't too confusing. Let's continue to the next lesson and very soon we will try to use all what we've learned in John example. So we can learn better of how to use the macros, how to use the events, and how to use the functions. 23. Function & Macro Library: So before we end this section, you can actually create libraries to add functions there and macros there that you can use globally between all of the blueprints. And this is pretty useful if there is a function that you have to use everywhere, you will have to put it inside of the library and you can access it everywhere. So I just, I just wanted to show you how to make a library before we go to the example. And let's make a new folder. If you right-click and make a new folder, Let's call it blueprints. It's always nice to be organized. And inside of the blue Blueprints folder, Let's go inside of blueprints. And here you can make a blueprint function library or a blueprint macro library. Let's make a blueprint function library. And for this library, you can call it anything. For example, let's close verse called library for now. And if you double-click it, you can see here that now we are inside of a graph, and this looks just like our event graph that we worked on over here. But this is actually the library and it only contains functions. So let's say I wanted to use a function, for example, to print out a message. So I'm just going to call myfunction print message. And this function is just going to contain print string. And I'm going to say this is from my library. Okay, so now it's going to print a message saying this is from my library. If I compile and save can also add a return node if you want to make it look clean. Okay, then now we can access this function because it's inside of our library, we can access it anywhere. So if I go back to my Level Blueprint and over here, I'm going to write the name of this function that I made. I'm going to go back and I'm going to write print message. And now you can see inside of a class and library, you can see the print message. And also if you go down here in class and library, you can see all of your library functions. Okay, so you can click on print message. And now if you connected, and let's compile and click on play. Whoops, we can play. You can see this is from my library. So this is how you make functions inside of libraries. If you want to access them everywhere, you can see that they do not pop up here because the function is not made inside of here. They are made inside of the library. And if I make multiple blueprints, which we will do later, you can use the function in all of these blueprints. Instead of going inside of each blueprint and trying to make the function the same function, they'll be just a waste of time. So going inside of the library, creating the function that you will use all the time. And then going back to all of these blueprints and using this function. Now remember you don't want to make all of the functions inside of here, only those you want to use all the time. So if there's a specific functions inside of here, you're not really, you don't really want to go in here and make it because maybe you only want to access it here or you want to access it between two different blueprints. This is only used for when you really need to access blueprints all over the place. And remember that this will actually affect the game performance if you have a huge, huge, huge library that you have to access, remember only to use it when you have to use it. For example, in this case, let's say we want to print this message in all blueprints that we have. I'm going to use it and only use it if you have to access a function many, many places, and not only just one place over two places. So there isn't really a rule for one to add it here. But you can just try to judge when you want to add it here and when you want to make it inside of here, The same thing goes with the macros. I don't really want to make one, but let's just quickly make the library. And you can see here, you can choose what kind of library you want to make. And this is a bit more confusing because we haven't really talked about those. And if I click on actor, you can see here now you have a macro. And this macro only works for actors. And I don't really want to get into it for now. We have lessons for this. So let's now talk about just to say that you can create libraries for macros to, and you can create all of the macros you want to create just like we did with the function library. All right, let's go over to the next lesson and let's take an example of all what we've learned and try to learn better by doing it in practice. 24. Events, Functons & Macros Example: Hello and welcome back. Now let's try to use all what we've learned into this example. So right now I have this map called the map tutorial that we made earlier. And it was just a symbol map that I made, call it Map Tutorial. And this is it. Nothing is inside this map, so it's all empty. So what do we want to do is firstly injured the Level Blueprint. So up here in Blueprint, open the Level Blueprint. And right now it's empty. And I usually want to delete this for now. So it's fully clean and it's fully empty. So to begin with, we want to, what I wanted to do for this example is I want to make three planes, so three different grounds. And these planes will erase again against each other until they reach a goal. And one of them will win when it reaches the goal. So it's some kind of arrays race and you have to click the button to erase with the plane. Okay, so very simple game. It's not the next Counter-Strike, but I mean it's a start. Okay, so let's start and all we can start with is add the events or we can actually just add the planes first. I think that will make more sense. So let's create three shapes. We'll create a plane, or we will create a cube or a sphere. Let's, let's create a sphere actually as more cool than a plane, right? Three spheres, and we have one here. We have one here, and we have one here. Okay? And by the way, if you want to duplicate, you have to hold Alt while you drag. This is how you duplicate. Okay, so now we have three planes and we can increase the shape of them or we can let them be. That's up to you, but maybe it doesn't really matter for this. It's not a competitive game. We can make this size to R1 and a half. Also a trek to not change all three numbers, we can just click on this lock. And this way we can just change one number and it will change all three. Okay? I will just put these spheres above the ground. Okay, So it doesn't matter too much. Now we have three different spheres. So what I want to do now is click on the first fear and dividend name. So I'll call it small sphere. Click on the next, call it medium sphere. And click on the last one and call it loss sphere. It's always nice to give them names because in programming you need to know which is which. Okay? So now I have these three different spheres and what we want to do is we want to add a trigger bucks. So if you go to Create, you have something called a Bugs trigger. And if you press G, So you can see all the icons. This is a box trigger and what this means is we can actually we can actually make an event or something happens when you overlap this trigger bucks. So I'm going to scale it up, pressing R to go to the scale tool and just scaling it up. You can also scale it up here if you want in this Details panel. But it doesn't matter, It's up to you. I'm just scaling this way and placing it in the middle. So it's like a gold line. Okay, So now we have a goal and make it a bit larger, so it covers everything. Okay, so now we have this and these three spheres will raise against each other and one of them will, will, when they reach the goal faster. Okay, so let's save everything. Now this is our simple level. Let's go over to a blueprints and create the gain. So open the Level Blueprint. And here we want to erase with three buttons. So we want to control this sphere with the EE button. We want to control this one with the R button on the keyboard. And we want to control this one with the T button. And let's go back. So these are actual events. So if you click E here and maybe write key, you don't find it, just go up. And this is the key. So this is an event for when the EE key is pressed or released. So click on it. And you can see here this is actually an event because this is a red node. This means it's an event. And let's find the R key. And let's find the cheeky. Okay, so now I have the E key, key and tiki, so these are events. So if we click the E key on the keyboard, what happens if we click the R? What happens? So what we want to happen is we want to move these fears, okay? All right, so. Let's actually do this. Let's make them move. So over here, we want to get a reference to the sphere to begin with, with the E key, we want to move this sphere. So I'm clicking on this sphere and then I go back here and right-click and click on, create a reference to small sphere. Now that we have a reference to the small sphere, we want to set the actual location. So if you just write a location to find the correct node, can see here we have something called set location that we have used previously. Okay, so when you press a, you want to set a new location for this. So what should the location B? We can't really make it static. Because if we make it static, like if we press, if we press E Now, let me make it 50 or something like this from pile and clicking play. So if I go here and I click E, you see nothing happens there. This actually because it says to you, this mesh has to be movable. Else you can't move it in game. So click on the meshes and click on movable, movable and immovable. And let's try again. Let's save, save everything, and let's play again. Now when you click OK, now you will move it 50 and a few click E again. Nothing happens because this is actually a static number. You're just moving it to dislocation. You're not moving it every time you proceed. So what we want to do is we want to get the current location of the sphere. We want to add a certain number to it, and then we want to set the location by this number. So let's try to created maybe it will get more explanatory when you see it. So to begin with, let's disconnect this. And for the sphere, Let's try it. Get accurate location. And easier way if you don't know what it's called, just right location. And you will see the get actor location. Okay, so now we have the location of this actor which is over here. So what, what do we want to do with the dislocation? And we want to move it along the x-axis. Because you can see here on the pivot point, this way is actually the x-axis, the red pivot point. You can see it here. It's dx. And we want to move it along the x axis this way. So what we want to do, we want to go back here and we want to move it toward the x-axis. So we want two plus d x axis. We want to change the value. So this one is a vector. And remember, a vector contains three numbers, x, y, and z. But what we, what we want, we want only to edit the z value. And we can do this by dragging out here and writing break vector. So now we're breaking the vector into the x, y, and z. And we only want to change the x. So for example, plus, and actually, I think it is, I think it's negative because, whoops, Now I minimize it. I think it's negative because we're going this way. This way. This is plus, this is minus. Well let's just go back and write minus minus 7. Maybe we should just have written subtract ten. Let's try this. Okay? And now we want to make the vector, we don't want to change the y and z values, so this should stay the same. So now here you can make, you can make a vector. So make vector. Okay? So now Meg vector, this is correct, this is plugged into the x and the y and z should stay the same. So by doing this, we actually broke the vector. We edited the x value, and then we made the vector again. So now I have the vector again, but this time we actually changed the x value. So what I want to do with this is every time you press the E, you want to subtract 10 from the x. So this way you move it by 10 and return to proceed. So now this new location is this. I'm going to set the actual location. So now before we click play, remember to add this small sphere to the target. And you can actually double-click on this, this line. And this will create this this node here, which is a connection pin. And you can move this around, and this is a good way to organize your code. So this is pretty cool. And I use this to organize the code. And now it should actually work. So if you compile and click Save, save everything and click Play. You can see here if you click E, you are moving by 10 every time. If I keep clicking E, I moved by 10 every time. So this is pretty cool. And maybe we can move it a bit more of this is very slow. Maybe you can move it by 20 instead. All right, so this is working. And the next thing I want to do is I want to print a text on the screen to show me how many steps I have taken. And this is just simple like we did before. We can just use a print string. And let's see what we do. We can actually make a custom events. So let's make a custom event. And this event we can call add steps. Okay, and we need a variable for this, something to store our amount of steps. I'll make a new variable, call it. Let's call it steps taken. And over here we change it to integer because it's a number without decimals. If it was what? Decimals we would have chosen float. But this is a number without decimals, and this is why we choose integer, hold Control and drag it out to get it here. And we want to, we want to add one step every time you press E. So just write plus plus, because plus, plus is adding one to the specified value, then it said it automatically. Okay? And we want to print this value. So print string and connect this. But now it's going to print every time we press E. Okay, so remember, this event is not going to work currently because we haven't really told the game went to call this event. So remember, every time you press E, you want to add one step. So over here, write the name of the event. Over here, click on Add steps are right as steps to call this event. So now every time we press E, we are going to move the sphere and also call this event to add one steps to our variable. Okay, so now we can compile and click Play. We can click on E. And you can see here it's actually moving and it's also printing on the screen how many steps we have taken. Okay, so now that the steps are working, Let's make something for fun. For example, if you take 25 steps, the game will tell you you should probably stop playing the game and start developing more because else you want to be finished with the game. So for example, here in the steps taken, Let's write equal. And maybe I did it too fast, I'll do it a bit slower. So write the equals sign, choose the equal. And over here you can double-click, make a pin to make it more organized. You can actually mark these two and click on cue to make a straight line. And you can drag out of this and click B to create a branch and connected. Okay, So now you're saying, is the steps taken equal to, let's say 25. If this is true, then the game will do something. And if it's false, it will do something else. So in this case, if the steps are not 25, We won't do anything. If the steps are a 25 we want or we will print a string saying, stop laying and start developing again. Okay? So it will say is that you should probably stop playing the game and do some organs that Let's compile and save. And now it works. We can set it later, but this should probably work. So if I go back and now we want this goal to work. So in order to make it work like we want, if this sphere hits this goal, we wanted to print out that this small sphere has one or this medium sphere has one and so on. So we want to do is click on this trigger box. And while we have clicked this, let's go back to our event graph and the Level Blueprint. And let's right-click, go under Events, go under collision, and then click on the ad on Twitter, begin overlap. So this is the actor begin overlap event. But what happens when this trigger bucks is overlapped? And we want to print a message saying that this sphere has one. And what sphere has one. We want to get the name of the sphere, and this is actually the other actor. This is the actor that is, let us colliding with this trigger bucks. So we want to get the name of it and you can just write name and you will see something called this get disciplining. They'll get display name is actually this name up here. This is the display name. So we want to get the display name. And let's try to hook it up and see what happens. So we want to just split the name for now. We'll click Play. And you've looked E, can see nothing happens. And why is that? This is because you have to click on the sphere. And down here under collision, there's something called generate overlap events. If you don't have this checked, you don't, you can't do any overlap events. So check this sphere that it is able to do overlap events and save it. Fragile click Play and click E. And you can see here to the top left that it says small sphere. And this is correct. Okay, so let's make it more interesting. Instead of only saying small sphere, we just want to print the message instead. So let's make a new variable, make a new text variable, and call it one message. And choose the variable type as text. So now we have this one message. Let's compile. And for this one message, let's say the, now we can't write small sphere because this will be static text. What is it, the medium sphere one. So for this to be dynamic, you actually have to use curly brackets. So curly bracket, and it doesn't matter what you write inside of this curly bracket. And inside of here, you can just write, for example, I will show you the and then curly bracket. Start. You write something inside of the curly bracket, and then you end it, and then you continue. Or a sentence, for example, like this. For example, the small sphere has one or the medium sphere has one. Now to make, to fill this curly bracket space, you can drag this out. So this is the wind message and we have to use something called format text. So what format text is, we can actually format this curly brackets into some texts that we, that we add dynamically. If you add this when message to the format text, you can add a pin here. And you can see there's a 0 and this is our 0 over here. But if you can write anything you want inside of these curly brackets. If you write, for example, sphere there, something sphere has one. You actually have to click on here and also called a sphere. So you have to call it the same. And now you can, you can connect this get display name to this format text. And then you can connect this format text to the print string. So now it's going to say D. And the color brackets sphere is actually this text. So it's the display name. So for example, it's going to say the medium sphere, medium sphere, and then has one. Okay? And this will print to the screen. Let's change this to a green color. Let's make it 10. So we can see it. And let's click on play. And if you're lucky and you hit it, it's going to say the small sphere has one. So this is working. And what want to do is we want to disable the input so you don't, you can't click anymore when you win the game. So let's disable none display, disable the input. But disable input. And it's asking for a player controller. And here you can just write get player controller. So this is the layer, the player controller attached to this player. Let's compile and click Save, save everything. Okay, let's click Play and minimize this. And if I click E, and it's one, I actually press anymore because e is my up and down. If you can see it on your own keyboard, I can't click anymore. So this game has stopped. Okay, so let's go back and we'll actually have to make it work on everything else. So we also have the archae and the Tiki. So in order to do this, instead of coming here and copy pasting this code. And I'm doing this and connecting and stuff. This is bad practice. We have learned in earlier lessons. You can actually collapse things to functions so you can make them more clean and access them easily. So what I want to do is the only thing that's going to vary in these other buttons, the R and T is the spheres that we're referencing. So if we click on the medium sphere and let's reference it. So down here, this is for the minimum sphere one we click our and for the other one, it's the large sphere. So let's reference this one. Now I have references. So these are the only thing that will vary. This code over here will be the same. And so what we can do is this one is as an event, so we don't really need to collapse it because this is the same. So this one is going to be the same. And this is the only thing that's going to vary. Okay? So what we can do is right-click on this and select the collapse to function. So now we have gloves to a function and let's, let's call it move sphere. Call it something that makes sense. So we can that makes sense for us later on. Okay, so if I double-click the, if I double-click the function we just made, and I just move things down so it's a bit more organized. And you can see here, it automatically creates input for us. And if we double-click it, you can see here these inputs are connected. This is a bit double. We don't really need these two because this is actually the same. You can see here it's connected to both. We just need one of them. And what I'm going to do is click on this starting node and I'm going to delete one of them. So I'll going, I'm going to delete this button one. And I'm going to call this sphere. Sphere actor is maybe a more specific name. So what I'm going to do is connect it here. So now this is the sphere actor. So over here, I'm going to click Alt and click here to disconnected. So now it's more correct. This is the sphere actor that we have connected. Okay? And this is the add steps, which is this event that is called Down here. So now what we can do is we can use this moves sphere. So if I compile and save, and let's double-click it, this is looking fine. Let's go down here. And what I can do is just drag out the smooth sphere and I can connect it. And now I can connect this medium sphere, the sphere actor. Now this, this is the one like down here. It's the medium sphere that is being connected to all of this. And down here, we can copy paste it. And this is going to move the large sphere instead. So this is very clean. Instead of copy pasting all of the code. If you want to make it more clean, doesn't really matter, but you can write return, the return node. So if you just write return, click on the Add Return node. This just looked more, looks more clean. It doesn't really add more to the code, but looks more clean. So that's fine. Let's go back to the Event Graph and let's see what we're missing. So we need to add steps. Let's just add steps here so it adds to the total amount of steps. And we're calling this event every time we click, let's click Compile and Save everything. And remember to click on these other spheres and take the generate overlap events. Else you want really overlap this trigger bucks. Okay, So save everything and let's click Play and test it out. So if I click ie, I move this bicyclic are, I move this sphere, and if I click T, I move this sphere. We can see here it adds to the total amount of steps whenever I click. And if I, for example, wanted to win with the medium sphere, it says medium sphere has one, and I can't really click anymore because I have disabled the input. So this was a small and simple game. And if you want to see this Trigger box inside the game, because you can see if I click Play, it is invisible. You can click on this trigger box, go down here and uncheck this actor hidden in game. So now I can see it in games you want to play, can see the Trigger box in front of you. Example I wanted to show you, and it was a bit a bit more complex than what we usually did in the other lessons, but still very simple. And if you want, you can use the begin play event to and say, for example, the race has started. Go, go, go. Something like this, whatever you want. And so now when we started the erase, it will say the, the race has started and you should probably race now. Okay, so when we go back, what we did is we have this begin play. It, it prints this text out. And then we have these events, the E key, the key, and the Tiki. So if I just place them up here so it's more organized for you. So we have the Yuki, the archae, and the Tiki. Okay? And when you present is key, something happens. And what happens is you move the sphere. And this is the collapsed function that we made. You can access it through here, or you can access it by double-clicking here on the functions. Can see a tab opens up here. So you can switch between the Event Graph and the collapsed function. And inside this function we have an input, and this is the sphere actor that we have to insert depending on which actor it is. And this can also be made by just click on the plus here and searching for actor. So it's this actor and you can even make other actors. So this is how this is made. This, this was made automatically, but now you can see how you make it manually. Okay, So this actor was made and so we get the actual location. We break the vector, which is this one. We only want to move the x axis. We make the vector again to make it, to make it back into a vector. And we added as the new location for this sphere. Okay, so this is the most sphere and then we add steps. And this is the event that we made here is calling the event. And every time we click on E, it will call this event, which will plus 1 on the steps taken. And it will bring you to a screen. And if it's equal to 25, it will say stop playing the game and stop playing and sub developing the game. And lastly, when you overlap with the goal or the Trigger box, it will display a one message. And this one message has these curly brackets called sphere. Is this one over here. The sphere is the name that will show the display name, which then shows dynamically instead of us writing a static message. And you could have called it whatever you want. You could have called it candy. And remember to change this name to Candy 2. And this will work as well if you disconnect this connected to candy and just right-click and click Refresh notes. So now it works as well. So it doesn't really matter what you call it, but just call it something that makes sense for you. And then we print this final text to the screen by print string. And we disable the input whenever the player has won. And another final thing, if you want to make more out of it, remember to comment your code. So here for example, it can mark all of these, click on C and click on E and C events to move new sphere. I don't know whatever he wants. I don't want to make this video too long, but remember to comment all of your code. This is a good practice. And because for example, in 15 days, if you come back, you can't really remember what you've done. And this is very easy to just see all the comments and see what your finished. I hope this has been helpful too. And if something is confusing or something you want to know more about, please let me know and I will answer in the comments or inside of the discord community server if you're in there. And I'll gladly help you out. It's awesome that you have made it so far. This is really, really great progress. So now we are going to go to more advanced stuff. For example, the arrays. And later on, we will learn more about how to set up characters, how to use a player controller and all of these things. So thank you for watching this lesson and let's go over to the next one. 25. What are Arrays?: Okay, so it's time to talk about arrays. So what an array is, a collection of elements. So here I have taken a picture from Google just to explain it to you before we get to work inside of the engine. So here you can see an array. An array is simply just a box and it can be as large as you can as it can be. So it doesn't have to be these five slots. It can be as long as you wanted to inside of the game. And it's a box and it's divided into small sections. So you can see here at sludge 0, you have some information. At slot one, you have some information and so on. In an array, you can store multiple information. Let's say we have an integer, a number of variable inside of the game, and we make it into an array. This means that we can store multiple numbers inside of here. So at slot 0 we can have a number, for example, five. At slot one, we can have another number, for example, 23 and so on. So we have a collection of numbers or collection of elements and we can use it during the gameplay. Now another example to make it easier is if you imagine this is an inventory inside of an FPS game, for example, Counter-Strike. And at slot 0 you have your knife. At Slot 1, you have your PESTEL as lotto. You have your AK-47, a slot 3, you have your grenade, and so on. These are all called actors in the game. And so you have information in each of these boxes inside of the array. So during the gameplay, you can choose to call some some information specifically. So for example, I want to use the information which is stored at slot t2. So this is what an array is. It's simply a collection of elements that we can use during gameplay. So let's jump into the engine and maybe it will become more clear for you if it still sounds confusing. 26. Creating an Array: Okay, so here we are inside of the engine. Let's go ahead and make our first array. So let's go over to the level that we created. Okay, So I'm in here and inside of those level I'm going to go into the Level Blueprints. Okay, this is the example we made before, but let's ignore that for now. I'm just going to disconnect the begin place so we can use it up here. And the way you make a, an array is just simply creating a variable because arrays are variables. So here, create a new variable. And for this one, we are going to call it character names. We will have a bunch of character names inside of this variable. So character names, this is some sort of a text and this is, we can do it with a string. Remember, it's always good to use these. The one that requires smaller memory if you're able to texts are, you are able to localize them. You are able to translate them into different languages, for example, German or Chinese. But names really don't need translation so we can live with a string. Okay, so now we have some, some character names. And if you drag this out just normally like we did before, this is just a normal variable and this is not a string, I mean not an array. So let's deleted. And the way you make it into an array is over here to the right. You can see there's a small, small button. If you click on this small button, you can change it into different things. So right now we're working with arrays. And here you can click it and see that it now becomes a bunch of boxes. And now we have an array string variable. So let's drag out this string variable hold Control, drag it out into the Event Graph. And you can see here now it looks a bit different. If I, if I drag out another variable which is not a, an array, you can see the difference. This is around pin. This one is a square pin. So now this is an array, this is a normal variable. So now we can add some information to our array. And before that, just like we did with the variables, remember to compile before you can add information to it. So Compile and Save. And here you can see you can add elements to this array. So instead of being a string, so let's, I'm just going ahead and creating a normal variable. So I'm just going to call this character name, and I'm changing it back into a normal variable just so we can see the difference. Now this is a normal variable, this is a, an array, and these are both strings. So if I compile, you can see here this character array or this character, sorry, normal variable. We can, for example, write a name and we can write John. So now we have John here. And in this array we can have multiple information. Remember that this is a set of boxes and we can have multiple information in here. So if you click here applause, we can write John. This is in the index 0. And the next index we can have my name. And the third one, we can have Kasper. In the fourth one, we can have, I don't know, snake. And one's called snake from Metal Gear Solid. We can have Viber. So now we have a bunch of names. We have five names, and remember an array always starts at 0, so erase never started one. So it's not 12345, It's always 01234. So it starts at 0 and you can add as many as you want here if you need. And now if we want to print this out to the screen, would, would the print string function, we can't really do that because remember this is an array, and arrays have this box looking thing here. And this is not an array as a nominal variable. So if you drag it over, it's going to say array of strings is not compatible with string. So you have to do something before you can print it out to the screen. And this is what we're going to learn in the next lesson. But before we finish up, remember that you can create a race with all the other things. So I can create an array of integers. So numbers, and I can call this, I don't know, maybe character levels are not very creative right now. So we have character levels and you can change it into an array. Okay? So now this is an array. And here you can again Compile and Save. And you can add all the numbers you want to this array. For whatever you need. This could be levels of players and you can add as many as you want. So you can have an array of numbers, you can have an array of text. And I'll show you in the next lesson how we are able to access these information in these different indices. 27. Array Functions: Okay, so now that we have created our first array, let's go over and talk about the array functions that exist. Obviously, I'm not going to cover all of them because there are many of them, but I'll show you how to find them. So if you drag out of this array and you go to Utilities and you go inside of the array here, you can see we have a lot of functions that we can use for this array. So for example, if we want to print the length of this array, the length is five. Remember we have five different names, so it starts at 0, ends at four. We have five different information here and these we can print. So now we're getting the length of this array, and this is five currently. And this is the number, this is the length of the array. We can print it to the string to see the length of it. So we can compile and click Play. And it's going to say five up here. So if I make it just a slightly longer so you have a chance to see it. It says five up here. Okay, So now the length is five. And for example, another one is last index. So the last index is four. Remember it starts at 0, ends at four. So the last index will print out 45 of the compile and click Play. You can see here it says four. And you can imagine you have different uses for it when you're programming the game. Whether you want the last index or whether you want the length of your array. You can also find specific information inside of this array. So if you go back to utilities and arrays, so now here you can get gets information. You can also find an item, or you can also ask it if it contains a specific item and you can do something out of that. So for example, find item. And now let's find, I think we had John in here. Yeah, do we have genre has countless find Casper. So I'm telling it to find Casper, do we have Kasper in the array? And let's find it. Where is Casper? And now it's going to say, Here's inside of index two. So if we go back to the array and we go to index two and we see Casper like this. You can find specific information. You can also write get. And here you can get the information of, for example, index 3. I'm going to print it to the screen. And index 3 we have snake. So in index 3 we have snake. So these are the different array functions you can use, and there are a lot of them. Let's go back to array. And you can, you can ask if the array is empty. If it's empty, you can make a branch here, you can connect it. And then you say, if this is, if this array is empty, what do you want to do? If it is not empty, what do you want to do? So this can have specific uses as well. Let's drag out and see one of the last, last functions before we end the video. So we have the, you can get some random array item as well. So if you have an integer array, you can get a random number out of there. The length we've talked about, you can get the last index. You can ask if an index is valid. And you see here all of these are green, but you also have blue functions. Remember, the green functions we talked about earlier are the functions that get information. While the blue functions are the ones that set information. So setting here is you can, for example, a clear their array. So if you want to remove all of the information that is inside of this array, you can use the clear node and you can connect it. And now it will clear everything in this array. Okay, let's delete that. Let's look at another one. You can use ad, so you can add during your gameplay, during the game, you can add a new name. So for example, Let's add snakes. Snakes friend is going to be added to this array. And now I can, I can print out this, this index that is going to be added to, and I can click Play. And now we have index 5. Remember we only had index four here. So now snakes friend is added and he is in index five. So this is how you use the functions with the arrays. And you can imagine multiple uses for it. You can try to, the best way to learn this is just click on a function. I tried to use it, see what happens and you'll learn better this way. Later on, we are going to make our game. So when I have talked about all the basic elements in programming and blueprints, we are going to design our own game and there we will also be using arrays, try to place different functions, try to play around with the array. Tried to make different arrays from other, other variables and see how you can use them. And let's go over to the next section and talk about the execution flow. 28. What are Execution Flow Functions?: Welcome to the first video of the execution flow. So what the execution flow earlier we talked about is that the code is always ran chronologically. So starting at the event, we always go to the next node and run it. We are, we then run to the next node and run it. This one is going to run it and so on. We can't really jump from this to this without having run this code. So we have to run all the code chronologically within this, within this white line. And you can see here the execution order or execution flow can be changed with different nodes. For example, the sequence node, which we're going to talk about later. And you can see here we can, we can run one type of a code and then we can run another one after that. So it's not really going in a straight line. It is rather now going in different directions. And this is what we're going to talk about. We're going to talk about the notes that can change the execution flow and what each of them mean. So let's go over and talk about the S valid node in the next video. 29. Is Valid Check: So the S valid node is simply asking if something is valid and if it is, then you lunch a certain code. So for example, let's go over to our level. We created this game earlier. And you don't really have to have this game if you deleted the level, It's alright. I just want to reference an item inside of this level. So for example, the small sphere, I'm going to click on it, and then I'm going to click back on my level blueprint, Right-click and call a reference of this small sphere. And now you can drag it out here and write is valid. And you can see here that this one would be question mark. This is actually a macro. So now you're asking, is this small sphere valid? If it is valid, then do something, then let's print out to the screen and say this sphere exists. Exists. Okay? So what this node is doing is actually asking, is this sphere actually valid in the level? Is it created? If it is not, then do something else. Okay? And this is actually used a lot in the game because imagine if you have a character and you have, let's say a multiplayer game or just a single-player game. And the character has not spawned yet. And then you have some movement code. So for example, you click W to move forward. You're always going to ask if the character has spawned that because why would you run the code for clicking W to move forward if the character has actually not spawned yet. So this is a very good for optimization. Always asking, is this actually valid? Is the small sphere actually in the level? It is? Then go ahead and make the player able to press R to move forward, for example. And if it is not valid, then do something else. And what I usually do here, just some extra content for you. What I usually do is delete it. So delaying it with 0.2 seconds, for example. And after delaying it, I'm going to run this again. So it's going to run in like a loop until the player response. So you can imagine the player is selecting a team right now he's selecting, let's say it's Counter-Strike. He's selecting terrorists are counterterrorist and he has actually not spawned yet, he's selecting what you want to be. So this game is going to keep looping. Does the character exists in the level? Know the players actually still in the character selection, then the player is not valid, so the character is not spawned yet. So now I'm going to delay with 0.2 seconds and then I'm going, when it's completed, I'm going to run the code again and ask, is the character respond yet? And it's going to loop around and around until the player clicks the terrorist or counterterrorist and spawns inside of the level. Then it says yes, now the player is valid. Let's go ahead and do this stuff here. So this is how you can use the valid node. 30. Sequence: Though the sequence node is used to clean up your code. So let's try to make the sequence node, tried to drag out of this execution pin and right sequence. And you can see here we now have a sequence node. And this sequence node is used to clean up the code. So instead of having a long line of code, can now divide the code up. So for example, we can write here, print string. Now it's going to print first message. And I will copy paste it and link it to the second one here and say second message. So here in the sequence node, once you can do is actually clean up the code and you're going to say, do this in sequence. So do this first, then do this, and then you can do this and so on. So it's going to execute the code from this pin first. So it's going to say first message. And if we had a long line of code here, it's going to execute all of that code first. And then it's going down to execute all of this code after it. And then it's going to execute all of this code down here. And you can make as many as you want. You can make it as long as you want. And this is the sequence node is very cool for cleaning up the code. So instead of having one full line of code, if it makes sense to divide it up, go ahead and use the sequence node. So for example, down here in the game we made previously, it doesn't make sense to make a sequence, but I actually just want to show you because this is fairly small, the code here. And what I want to do is just move this a bit further away. And I want to make a sequence note here. So I'm making a sequence. And now it's going to say, when you run this event, first, do this code over here. And I don't want, I don't want to do this together with this one. So I'm going to unconnected and move it down here. Let's move it down. And I'm going to link it over here, okay? And I'm going to again either link it back like this, but I think it looks messy, so I'm going to copy paste it. That's the same and just use it down here so it looks more clean. Okay, so now I'm actually doing the same, but I'm doing it through a sequence node and it looks a bit more cleaner. So it's going to say when you run this, this event, run this code first. So adding the steps and printing, printing it to the screen, and then go ahead and check if the steps are equal to 25. So this is the same code, nothing different, but we actually divided it up into different sections. So sometimes it makes more sense to divide it up. So it's not in full line of code and it looks, it looks a bit messy if everything is together. So use their sequence denoted to clean up your code. 31. Flip Flop: Now let's go ahead and create a flip-flop node, and I'll show you what that is. So let's go ahead and create an event. And here I want to have a keyboard keys. So for example, the F key, I'm sure at the F key, this event. So we can click on the keyboard and do something. And let's make the flip-flop node. So when you press the F, we make the flip flop node. And here, now in the flip flop, this is just like a switch. It's going to go from, it's going to execute the code in a. If you click, if you click again, it's going to execute the code in B. And if you click again is going to execute the code and a and so on, it's just going to switch all the time. So for example, if I write here, I'm going to write the code in a, I'm going to copy paste it and link it here and say the code in B. Okay, so now if I compile and click Play, and I see here this is from my old video. So if I click, if it's first going to say the code in a, and then it's going to say the code and B. Then it's going to say the code in a. If I click again, and if I press F again, is going to say the code in V. So it's going to switch between a and b. So this is what a flip flop node does. So you can imagine a switch on a light and you are placing the light and you can turn it on and off using the flip flop node. 32. For Loop: So now let's talk about the loops or you can look some certain code. So let's go over and create a loop. And for this one we're going to talk about the for loop. So writing the for loop. And you can see here, there is something called FOR loop. So this one for each is actually for arrays, but we want to use the ones down here. So for loop, and this is the loop. So now we can loop some certain, certain code. And this is the first index. So this is, this is variables from member variables always start at 0. And we can write, oops, I double-clicked it. We can write some other index. So for example, five. Now it's going to loop from 0 to the last index, which is five. And here in the loop body, what do we want to loop? So this is what we want to loop. So for example, I want to say hello 6 times. Remember we started at 0 and finish at five. So this is six in total. So I want to say hello six times. And when I finished saying hello 6 times, when it's, when the loop is completed, I'm going to say this loop is done. Now I'm going to say this loop is done, and I'm going to choose another color. And now let's go ahead and compile and click Play. And you're going to see I said hello six times. And then I said, the loop is done. So this is how you use for loops. So this can be hard-coded just like what we did. So you can write a certain number and compiling click Play. Now we're going to say hello 26 times. And then after we say hello 26 times, we're going to say the loop is done. And this is, this can be dangerous, like loops can be dangerous. Encode, because imagine you have a loop that is, that is 10 thousand and I'm going to try to click play and hope my computer is not going to blow smoke. And you can see here, I click Play and it's actually worked, but it took some time before it started playing. So if you have a very huge loop inside of your game, this can heavily affect performance because you have to go through all of the slope before you can, before it has completed. And if you're like, I have a very good computer right now. But if you have someone with a bad computer is going to lag, are maybe he's going to actually crashed from the game. So you have to be careful for the loops, but they definitely need to be used. We use them a lot when we code a games. But just be careful. Sometimes you are able to create infinite loops and these will definitely crash your game. And if you want, you can also print the index here. So for example, you can connect this index and you can see here the number of indices that are being printed. And what you can do instead of hard-coding here, you can actually, can actually plug in plug in variables instead of using hardcoding. And also another for loop. Instead of only using the for loop, we have something called For loop with a break. So what a for loop is, a follow-up with break is it looks like just, just like the for-loop from before we have the index, first index and last index we can set. And we also have the loop body. So what do you want to loop? For example, the print hello. And when it's completed, what do you want to do? But this time we have a break. So here you can see we have a, an, an extra execution pin. So let's talk about this break. So here in this example, let's loop something. So for example, we can, we can do a format text for this one. So format text, I'm going to write it down here for my text. Okay, So we have a format text and we can write some sort of alliance. So we can write the slew has been running. And we can write in the curly parentheses like we learned before. And doesn't matter what we write, close the parentheses and we can write times. Okay, so now we have the 0. We can actually put this index inside of this format text. And it's going to say this loop has been running, for example, 15 and then times. Okay, so now I have this format text and we want to print to the screen. We're going to print string connected. And now we're going to append it to the string. This is what we want to loop. Okay, and when it's completed, we are going to say the loop is complete. And let's try to compile and click Play. And you can see, actually I want to make this longer, so it's a lot easier for you to see. It disappears off the screen so quickly. You can see it says this loop has been running five times, from 0 to five times. And this break is, is we can actually break this loop in the middle of the loop. For example, if this loop has run too many times. So for example, let's say we have 1, 0, 0, 0, 0. So if I compile and click Save, you can see this loop has run for this amount of times. But what if we want to break it? If it hits 20 or if it hits above 20 times. So we don't want to run it more than 20 times. So what we can do is actually use it as a break. So here we need a, an event. So let's create a custom event. And we'll learn about those. Just write custom and click on the customer event, call it something. We can call it break the break the loop for example. And this customer events, we have to connect with the break, okay? And remember, the events will not work if you not call them anywhere. So the computer doesn't really know when to run this. So if you click on Play, nothing really happens because you never call this event, you never call it somewhere. And you have to call this event within the loop body. Because if you click play and you are going to loop, you are going to finish this loop before you do anything else. So you have to call it within this loop if you want to break the loop. So here I am going to say, if this loop is looping greater than 12 times, is it looking more than 20 times? And if this is true, if this is true, then we want to break. So I'll call this event over here. What you can do is just write the name of it, break the loop. This is what we call the event. So if it is greater than 20, then break the loop. Else if it is not a greater than 20, just go ahead and keep printing out this message. Okay, so let's compile and click on play. And you can see here, now we're running the loop actually 21 times because we're also counting the 0. But now you can see we actually broke the loop and it says the loop is completed. So this is how you use a loop would break while the for-loop without the break is going to loop everything without any break. But remember, if you use the for loop would break, you have to call this event within the loop body. Let's go over to the next video and talk about the while loop. 33. While Loop: So let's talk about the while loop here. Let's go over to the beginning play event. And from here let's drag out and ripe for loop or a while loop. This is what, this is about, the while loop. So now we have this while loop and this is before I talk about it, this is very dangerous to use. You should almost never use it in your game. You should use the other loops. But I will show you why this is dangerous. Because let's, let's create a condition here. So for example, let's create a Boolean and let's call it is dead. Now we're asking if the player is dead or not. There was changed into a Boolean. And you can see here this is an array right now, so it was changed it back to a normal variable. Let's take it out. And now it's asking, is the player that let's connect it. So this is very simple. It's beginning of the game. And this while loop is asking, is the player, is the player dead or not? So now we're going to look depending on if the player is dead are not. So right now the plan is not dead. So it's not going to loop. So let's print a message. So it's now going to say as the pleura dad. And only, this is only going to loop if the condition is true. So right now the player is, is not dead. So let's not going to, not going to print anything. So I'm going to click Play. You can see here it's not doing anything. But if the player is dead, we want to loop something, for example. And now it's getting dangerous because you can imagine this. When is this going to stop? This is an infinite loop. And this is never going to stop because the player is dead. And your urine, you are saying while the player is dead. So this is the wild loop. While this condition is true, loop this body. Okay? So it's going to loop this body until the player is not dead anymore. So now we have said this to true, and we haven't really specified when the player is not that anymore. So let's click Play and this is going to crash because this is an infinite loop. So if I click on Play, you can see here it's, it's lagging. Now it's going to say infinite loop detected. So this is an infinite loop. So while this, while this condition is true, loop, this body. Okay, So another better example to give up this, let's make an integer instead of a static or a static variable. So let's delete those. Let's go over and make a new variable. And let's actually just use this steps taken variable. So let's take this steps taken variable. This is an integer. And we can say while this number is, is greater, rash a little lower, while this number is lower. Then 10. This is the condition. So while this, while the steps taken as underturn, you're going to loop something. And when this is completed, you are going to print out this is complete. And for the loop body, remember, while the steps taken are under 10, so we have two while it's looping plus it. So let's take out this steps taken, and let's do plus plus. So we are going to add one to it every time. So remember, plus, plus is adding one to the specified value and then we set it. Okay, and now let's print it out. The amount of steps. Well, this is our loop body. So now what we're doing is while the steps taken is under ten, we're going to loop this. We're going to plus one step and then print it to this string. And we're going to loop this until the steps taken are above 10. And when this is finished, we are going to say this is complete. So let's compile click Play. And you can see here, this is how it works. You click Play again, you can see this appears again. So this is how you use while loops, but be careful with the while loops. They can create infinite loops quite easily. 34. Do Once & Do N: Okay, so let's talk about the dual ones and do endnotes. So let's go back to the Level Blueprint and open it here. Well, let's start with the, let's use the F key event for this example. So if keyboard and we can write here, do once, and now we have the do one snowed. So what they do once node will do is it will fire a certain, certain code just once, and it will not fire again unless you reset the code, reuse this reset. So for example, it will say, let's make something fun, Let's writes reloading. So you're reloading a weapon. And you can only do this once. Because you can see here if I click Play and I click f, says reloading, if I click f again, nothing happens. I can't click African because this is the dual one snowed. You can only do it once and you have to reset before it can do it again. So let's make another key, and this is the G key. And here I've made an integer. I can actually make it again. Let's make it again, just for practice. Make a new variable called bullets. And this should be an integer. Take it down here. And every time you shoot, it's going to minus1 bullet. So let's, let's start with 20 bullets. So make the default value of 24, this variable. And every time you press it's going to minus boards. And let's print that, that amount out to the screen. So let's do a format text just for fun so we can write. And you have that. Let's do you have then curly brackets to make the dynamic text bullets left? And here we can plug in the amount of bullets. So it's going to say you have, for example, 15 bullets left. And let's plug that in to the string here. Okay? And now we can try it out. So I click Play and click G. So now you have 16 bullets left, 15, 14, 12, so on. Okay, So that's, now that's working. And let's say if we are on, we are equal or equal. 0 bullets. If this is true, then we can reload. So for example here, we can have to make a custom event for it to reset. So let's make a custom event right, customer. And for this we can call and reload, plug that into the reset. So now we have to reset, we have to call event, remember we have to call events for them to work. So over here when we have 0 bullets and this is true, let's call the event and reset this one's node so we can do it again. So here we can write, can reload to call the event. So now it's when you have 0 bullets, it's going to reset. So we can actually, uh, reload again. So let's go ahead and click Play. And you can see there's a bug I can actually reload even though I have bullets to begin with. So we can actually start closed. Okay, this is what start closed mean. So if I click f Now it's not going to work. I'm going to shoot person do. If I have 0 bullets left, I can click F. Now can reload. And if I click f again, it's not going to work because this is the new ones node. I have to shoot again. But now I can see I have a bug because I haven't really told it to restart. But you can do it here. You can actually take the amount of bullets and you can set it back to 20. And let's try again. We can play. You can shoot the bullets. You can press F, you can reload. You can start to shoot again. But now you can still go and minus I haven't really checked part of that, but you can't reload. You can start again on the other rule of soccer. So this was it for now. I just wanted to explain that once node and this is what it does. It plays a certain code just once until you actually reset it, if you reset it. So the next thing is the do n node. So this is almost the same. You can maybe guess it. You can do a certain code n times. So this is the node. I'm not going to explain too much, but what you do is the same principle. You have. You can do a certain action multiple times. So for example, three times. So you can print or you can say, here is money three times. And when you do this, you have to reset. So let's use the G key to reset before I can give you money again. So we got to click on Play and I click Earth, here's money, here's money, here's money. And I can't press it again because I have said the n here, I've said the enter three times. So I have to press G to reset it, and then I can press F3 times again. So almost the same as do the ones node, but this is the duet node. You can set how many times you want to do a specific code. So for example, you give someone money and you have to do a certain job to research before they can give you money again. 35. Gate & Multi Gate: Hello and welcome back. So let's talk about our last flow control node. So let's go ahead and click on Blueprints and open our Level Blueprint. And what we're going to talk about today is the gate and OR gate node. So go ahead here. Let's do our Begin Play. And let's hook up to the gate. So pull out of the execution pen and Let go and ride gate. And here you can see the gate and msi gate node. So let's start out with the gate node. Okay, so what again note is, is simply you can imagine it as a gate in a castle. So you can close the gate and you can open the gate. And when the gate is open, you can execute some sort of code here. And if you close the gate, this code will not be executed. So this is the main principle of this note. So let me go ahead disconnected here. Maybe I want to use a keyboard key instead. That would be easier. So let's use the key, the key instead. Okay, So on our press E, it should fire or some sort of codes so we can fire this and just see her lower for now. Okay, so if I click Play and I go over here at point E, you can see that nothing happens. And this is because the gate starts closed. So fake words, low back and you can see here it says start closed and this is what it means to the gate is closed. I can fire any of this code over here. So if I open it and I compile like play, clicky, you can see you that I'm saying hello and now the gate is open. Okay, So an example for using this is, for example, if the game is paused, you don't want to fire this code. This is one of the example that you can use it. And there are multiple examples for when you want some certain code not to be executed anymore. So you can close the gate and you choose when to open it. So let me show you how to close and open the gates. Okay, So let's, let's make a cluster events. And this customer events going to be called open gates. And let's do another custom events. And let's call this one close gates. So we have two custom events. Look them up in the open and closed gate. And now let's have a, let's have the R key. So this one is going to open the gate so-called The, called the event. And when we press R, We're going to open the gate. And I could have done it like this, like connecting to the open gate and this would, this would actually just open the gate when I press R. But I just want to show it to a customer events. Because when you play a game or when you develop a game, usually you don't really have, you don't have keys, keyboard keys connected to this. You have customer events. So I'm going to connect the cluster event in stone. And what you want to do is just called the cluster event for it to, to play this event. And let's make the TQ the one that closes the gates. Personnel, I have an open gate and close. Good. Now let's compile and click Play. And now the gate is open to begin with. Whenever proceed, we can say hello. And if I press the the Tiki, it will close the gate. And if I click E, nothing happens because the gate is closed. If I click our anklet you again, the gate is open because I just opened it with the RP. So this is how you use the gate node you have. This is technically a gate. You can imagine a gate and a real-life and you can close it and open it. And when it's open, you can fire this code that's over here in the exit execution pin. And if it's closed, this code over here in the execution, and the exit execution pen will be ignored. And you can choose to start it closed or open. And here you can toggle so I can show it to you. Let's use the archae and connected to the toggle. Right now is going to be started open. I'm going to delete these custom events because we don't have them anymore. And I'm going to click Play. So right now I can say hello. If I click are, I can't say hello anymore. If I click Oregon, I can say hello. So this one toggles whether you close or open the gate. So let's take a look at the multi gates. Note. So if you write multi gates, click on the node. This one looks a bit more different, but it's actually the same principle. So let's disconnect this. Let me actually delete this here. Don't get too confused. And now we can connect this to our Iike event. Okay, so now we have the different outputs. So for example, we have four different outputs. So you can see here we have several execution pins compared to the, to the gate node. I can just place it up here so you can compare it. And would the mall tie gate node, you can fire, you can fire a different code in a controlled manner. So here we can say kilo one, hello to the lower three, and let's have a fourth one and call it hello four. And now we can connect these to the different pens. Okay, now let's click, Compile and play and see what happens. So if I click Play and I click E, gets here, it says hello one by clicking E again, associate law to the lower three and hello for, okay, so what happens here is when you click E and firing this multi gate, it always fires to the first one because you have this starting index. So on the starting index chooses where to start on these pennants. So if you have written to and click Play, it would say hello or three. So if I compile and click Play and I click E, it will say hello 3. So this index chooses at what pen to start, and the default is minus1, so it's always starts from the beginning. So when you press E and R multi-grade, it always fires this code first. When you fire this multi-state, again, it knows that it already fired this 0 execution pen. So it will go to the one and fire this code after. Okay? And if you fire the small, tiny note again, it will fire the execution pin from the two and so on. And when it finally reaches number three, it will stop the code. So let's try to compile and click Play. And let's click e, il a 1234. And you can see if I click E again, it's, nothing will happen. So this is the gate node. You will play all of the code and US replaying all of the code until the last execution pen. It will not work anymore. And to make it work again, like if you want to play the code again from the beginning, you have to take this loop. This is what it means. It will loop the code again. So if you'll click Play and click E, Hello, 1, 2, 3, 4. And if you click E again, it will start from the one. Now, now you can loop your code. Okay? And the last one, this is self-explanatory, so is random. It will choose a random code from these execution pens. So if you click play and clicky, you can see it chooses Hill 04. We click Play again, or a clunky again. It will choose her law 2 and so on. So it chooses a random execution pin from the scope. And remember if you don't have loop, it will not play this code again. You have to have loop in order for it to play again. Okay, so what you can do here, if you don't have any, you don't have the loop and you want to reset the code. You can always let say you are playing it in order. And over here you want to reset. So you're actually going to play it again and you want to control when you reset. So let's go over here and let's make a custom events. And let's call it reset gates, gator, and let's just call it the recent gator and hook it up to there reset. And over here in the R key, we are going to call a reset Gator, which is supposed to say Gates. And let's compile. Okay, so now we can reset the gates. So let's click Play, lucky until the code is finished. And now there is no more. Now I can press R and the gate is reset and you can play with the code again. So this is how you reset. And you want to reset whenever the score is finished and you want to lay the code inside of the multi gate, whereas the negate only has one execution pen. And you can choose to open and close it. Or you can choose to have a custom event that will toggle between closed and open. 36. What are Enumerations?: Okay, So welcome to this section about enumeration. And by the way, congratulations, you've made it so far. This is a really good progress and now we're going to get into the more fun stuff. I hope you've had fun learning about the previous notes. But for me I think this is now getting more fun. And also especially in the next lessons where we get about Blueprint Classes and so on. So congratulations, this is really good. So let's go ahead and learn about enumeration. So what, uh, an enumeration is, is just a list of items. So for example, you can have a list of vegetables, you can have a list of animals. You can have a list of items. You can have a list of weapons and so on. So it's just simply a list of anything you want. It can also be a list of your character movements. So for example, sprinting, running, crouching, and so on. So this is a very simple concept and this is a very, very powerful list that you can use. And I use it all the time. And let's go ahead to the next lesson and see how we can create this enumeration. 37. Creating an Enumeration: So to create an enumeration, you have to, let's go over and make a Blueprints folder. You can see I've already made it. If you don't remember how to make one, I'll delete this one and right-click on the content folder and choose the new folder. Call it blueprints, and it's nice to be organized. And right-click over here to the right inside of this folder. And now under Blueprints, we can create the enumeration. And the naming convention for enumeration is e. So I will always write E in the beginning, and let's call it character movements. So for example, crouching, sprinting, and so on. So now we have a list, a double-click the enumeration, and you can see this tab appearing. Now, this is a very simple here you can click on New to add a new item to the list. And here is the name of the item. So for example, we can crouch and I can call my other one walk and run. And I can add sprint. And you can add whatever you want. For example, let's say pruning. You can prune in the game as well. So you can add a bunch of items is just a list and you can even add potatoes and whatever you want. But this doesn't really make sense in the character movement. I'm going to remove it and let's click Save. So now we have a list of items. So let's go ahead and use this list that we have made. This is the list we made. So let's go over to the Level Blueprint that we've been working in. And inside of here, Let's make a new variable. And this variable we're going to call character movements. Always remember to call it whatever makes sense. So you remember what the variable is. And to call this, you can see here we have enum. There's already a lot of standard enums that comes with the engine. And some of them I have never used. There are some, so many of them. And let's go over here and call this E character movement. This is actually the list and that we made here. And you can also search for it. And this is very nice because we made a, made a naming convention here we made a prefix called E two. We can quickly find it. This is why you need to make them and just say character movement. And you can see here, this is the enumeration. So now this variable is an enumeration. You can also see it here as well. And let's hold Control, drag it out. And you can see here now we have an enumeration in the Event Graph. And you can also see that the enumeration is working by, for example, just printing out. And it will always print out the first value that you have in your enumeration. Though, let's go over and print a string. Let's connect it to the enumeration. And here we're, now we're printing the, the enum that were made. And let's click Play. And you can see here it says crouch, no, it's actually printing something from the list. And sprinting is actually this list. This, these are the default values and you, you can see here this is actually the list that we made inside of this enumeration. And let's say, I wanted to add one more movement. I can go ahead inside of my enumeration, add a new movement, and I can call it per hour patch crouched to, for example. And it can choose to move it upwards here. You're moving it up together with crouch. Now we have Croce two. If we save and go back to the Level Blueprint and click on the enumeration. You can see that we have now crouch to inside of our list. So you can imagine this is very powerful. You can create a list of anything you want, and you can choose the default value. You can also manipulate these values during gameplay. So let's go over to the next lesson and learn how we can compare this enumeration. 38. Compare Enumeration: Okay, welcome back. So now let's learn how to compare the enumeration. Or just like our integer variable or float variable, we can, we can write equal equal and we can have these operators and so on. We can actually compare the enumeration. So I dragged out of the enumeration. You can write equal. And you can see here is something called equal and not equal. So we can actually compare it. And you can also do not equal. And you can actually do this by doing the question or the exclamation mark and the equal, this means not equal and programming language. So now I can see here, we can now compare this enumeration. So for example, we can say is, is the enumeration set to sprint. And if this is true for the enumeration is sprint, then we don't want the player to fire the weapon. For example, I don't want the player to fire the weapon while sprinting. The player can only do it while running or walking. Okay? And if it's false, you can do nothing, for example, or you can do something else. And here for example, let's print out. If it's equal to sprinting. I'm just going to print out can't shoot. And if it's not, then, then it's okay to ship. And this enumeration. Now it's currently set to sprint. So now it's going to say you can shoot. And now it says you can shoot. And if you change this enumerations for something else, for example, you're running or you're walking, and you go play. Now it's okay to shoot. So you can compare an enumeration and see what it is, what the default is. And for example, in a case, you don't want the player to be shooting while sprinting. You can try to compare it. And if it's true that the player is, is a sprinting, then you could, for example, have made a Boolean seeing can shoot. And you can set this can shoot to false because now the player can't shoot. And now you can, you can always here for example, on this very simple case, if it's not equal to sprint, you can shoot. But this is how it can be used. 39. Switch on Enumeration: So let's talk about switch on enumeration. And first off, let's go ahead and delete the extra value that we added. So go back to the enumeration which were created over here. And I'm going to delete the crouch to because we don't really need it. And let's save. And let's go back to the Level Blueprint. Taylor's dragged out our enumeration and now try to write switch. You can see here is something called switch on and the enumeration that you have currently. So this will bring up a big thing here and don't be confused. This is very simple. It will actually enlist all of your, of your list items here. So now you can execute a code depending on what what you really want here. For example, if you're a player is crouching, you want to execute this code. If you're a player is running, you want to execute this code and so on. So you are going to execute a code depending on what the player is doing. For example, if this is a list of fruits, Let's say for example, we have a banana here, and we have an apple here. So for example, if it's an apple your player is holding, you can do this. If it's a banana, you can do this and so on. Now in this case we have switch and genome, and in this case, for example, we could change the movement speed of the player. So let's make a new variable and call it movement speed. And let's change the variable to a float because we need a number with decimals. And let's bring it out, hold Alt and bring it out to sell it. And for example, for crouching, we want to set the movement speed of 50. This really doesn't mean anything right now. I'm just writing numbers and we can copy pasted. And we can, when the player is walking, I want him to move a bit faster, so maybe 70. And when you are running, we're going to move 100. When you're sprinting, you're going to move 150. And when you're pruning would say you're not able to move. So I'm going to set it to 0, 0, let's connect all of these. And now is going to execute the code depending on what the enumeration default value or just the value in general is. So let's go ahead and write a print string. Well, let's print it out to the screen. And let's go hook up all of these movements speeds. So we can actually see that it's printing it out. Okay, So this was the last one and I'm going to move them up a bit so it's more clean. It can get messy really quick. So remember to clean it up and make these these lines bearer, but I don't want to make the video too long right now. So let's save and click Play. And you can see here the default value right now is walk. So it's going to set the movement's be 270. And if I click Play, you can see that it's, the movement speed is actually 70. And if I was, let's say sprinting, our sprinting, the movement speed will be 50. So this is very powerful and you can also use it on user interfaces. And I'm going to make a course later about user interfaces. And this is very cool because you can have a list of windows, for example, Main Menu. You can have the character selection screen, you can have the profile screen and so on. And you can actually run a certain code depending on what window it is. So these are enumerations. They are very easy to learn. It's just a list. And if you want to add more to the list, go back to the enum that you created, add some more stuff to the list and go back and they will appear down here. And then you can add more coded depending on what you need to do for each of these execution pins. 40. Enumeration Example: Hello and welcome back. Before we go over to the next subject, let's go over and look at an example. So if we play, this is what we're going to make. It's going to say welcome friend, please press E to eat a random fruit. And now when we press E, and it's going to say, it's going to choose a random fruit. And in this case it chose a banana. And it's going to say you're hungry meters now 20 lol. If you want to eat more, press R. And now if you press R, you can eat more. And then it chooses a strawberry this time. And the next time you can choose another one, It's a coconut and so on. So, and the hunger meters going up every time we eat something. So we are going to make this example and we're going to use what we've learned so far. Let's go ahead and pull up the Level Blueprint. Okay? And what do we want to begin with is our usual begin play van. So begin play. And here we want to print out a text. So let's print out hello friend. Press E to eat a random group. Okay, and now we have to make the E key, so writing in the keyboard E key. So now we have this event, and when you click E, you want to eat a random fruit. As for the fruit, we have to make a list of fruit. So we have to make a, an enumeration. And let's go over. And you can see I have this from my other video. So I want to delete it for now so you can see how you do it. And I can right-click and do blueprints, enumeration. And here I can call it E fruits. Okay, Let's say everything. Let go inside of this list and make a new route so it doesn't really matter. So choose whatever you want. We can make strawberry again. I'm just going to choose the same food that I have. Coconut. And the last one was like nipple. Okay, so you can add as many as you want. We have these four for now. Let's close down the enumeration and let's go back to the Level Blueprint. And in here, when you press E, you want to select a random enumeration. Though let's make the variable and call it fruit. And let's change the variable type to our enumeration list. So E fruit, this is what do we call it, and select it here. So drag out and drag out the enumeration and hold all so we can sell it. And now we want to set it to a C here, and let's copy paste it four times. And let's change the, the value here too, all of these different fruits. So when you press E, we want to select a random fruit over here. So the way we can do it, we can actually use our multi gates. So you use the multi gate here and connect four pins to it. So add more pins that, and let's add them here. Okay? And we can take random, so it chooses one of these randoms and we can connect the button. So now when we click E, It's going to choose at random one of these pins. So it's going to choose and set our fruit variable to one of these random fruits. So if we proceed, there is a chance it will choose this pin and our fruit will be set to coconut. Okay, so when the fruit is set to a specific value, we want to eat the fruit. So we want to make a custom events. And let's call it eat fruits. And here let's start with printing the text. So we're going to print UV. You've eaten a. Actually, I want to teach you something else. Let's do something different here in this, in this tutorial because I want to teach you something new. Let's take out this fruit variable. And we can use something called Select. This is very useful. So what a select is, it selects one of these options depending on what your value here is. So if you have set your variable to coconut, it's going to do whatever you have said it here into coconut. So right now you can see everything is grayed out because that is because these are wildcards. You have to right-click and click on Change pin type. Then here you have to select a variable. And for example, I want to, I want to write a text. For example, if you eat a coconut, it will say, Oh my God you ate or coconut. Or if you eat a banana, it's going to say you who ate a banana. So this is a text or a string that's up to you. So I'm going to choose text. And you can see here all of them changed color. They are now text. Okay, so now you can actually write something, but also have changed it to something else. Maybe you wanted the numbers and then you could choose numbers, but let's choose text, the text, and I want to show you what it does. So select. Right now if we click E, it chooses one of these random, it's going to set it to a random fruit. And if it sets it to pineapple, for example, it's going to say, Nice. You aid a pineapple. Okay? So nice to eat a pineapple. So this is what is going to say. It knows that your value is pineapple, and it is therefore going to select this value. This is what select is. So it depends on what the value is. It's going to select this. So it's going here. It's going to say young. It was a banana or oh my god, a strawberry. Or the last one. Awesome. A coconut. Okay, so depending on what the value is set, it's going to select. So for example, if it's coconut, It's going to select and see this, this text. So this is what a select is and we can print it out to the screen. So let's hook it up. And now it's going to print it out to the screen. And now what we also want to do, we also want to do a hungry meter. So it's going to display that your hunger emitter is going up. So depending on what fruit you eat, you have different girls, so it increases with different numbers. But let's make a new variable and coral call it hunger or fullness. That's up to you and let's make it an integer. Okay, so now we have a hunger and we can use this hunger and set it to different values. But now we have to use this switch, switch on enum because we want different values for each of these fruits. So what we can do with the switch on enum here, or we can, just for practice sake, we can use the sequence that we learned. So sequence, it's going to do this code. And after it finishes, this code is going to do which on enough. And now it's going to switch on INO here. So it's going to do this first. And then it's going to fire this guy over here. And depending on what it is, we're going to set the hunger two different values. So for banana, let's set it to 20. And let's go paste it a few times. And let's change these values to different values. Something like this. It doesn't really matter what you change them to. This is just practice. Okay, so now we have this hunger and it's going to display to the screen what the hunger meter is. After doing this, we can print to this screen. Or we can actually do the format SEX. That's a lot better here. So it's going to say your hunger meter is now. And then we have a number. And let's just say, nice. If you want to eat again. Press R and I will show later on what we will make the are a bit later. So let's focus, focus on this for now. So now we have this hunger emitter and we wanted to increase every time you eat something. And you can imagine if, if we set it to something like this, every time you press E, It's going to set it to this static number and it's never going to increase. So we need a new variable and let's call it hunger meter. And this hunger meter is going to say this hunger meter, loss, this hunger. So now we have 12 in total. And then we are going to set this Unger meter. Okay, so now we have this hunger emitter which is 0 to begin with, and we add 20 to it. So now it's 20. And the next time we press the button and we eat another fruit, this value will be 20. And let's say we aid a pineapple after that. Then it's going to say, let's put it down here as the hunger mirror, that is going to say 20 plus 80. And now it's going to be 100. So we're, we're adding the, every time we press, we're adding the hunger to the hunger meter, which is the total value. And it's going to set the new value here. So we need to copy paste this couple of times. And sometimes coding is like this. You have to copy paste. So let's, let's move it down. And I can actually do this in a smarter way, but let's keep it fairly simple. I don't want it to be very confusing. We can always move on to more complex courses later on. Though, let's copy, must set the hunger emitter wires up here too. And I want to pull them down and we have more space. And let's add this wood. This was plug everything in so it can get messy quickly. But I talked about that we could do an smarter away. We can actually do this into a function, but let's keep it simple for now and do it like this. But if you want to see it in a function, I can, I actually can't look at this. So I want to make it a tub watching quickly just to show you collapse to function. This is what we learned before. You can collaborate this to our function. And you can call this add hunger or something like that. It should probably be called fullness. There are going to add this number and this, instead of setting it out here, we can actually add it to the input here. Okay? So what this does, this actually adds an input out here in the Event Graph. So now we can actually add hunger here. And we can add the young, add the hunger here. And it's going through the code, setting the hunger, placing it with the hunger meter. And now we have this hunger meter. So actually, let's actually do this. We actually learned previously how to do the collapse functions. And we wanted to do a bit more advanced stuff. So I hope it's not too confusing. And let's connect everything. And now you have add hunger. And now we want to display this text. So now we want to display the hunger meter, which we will connect here. And let's print this to the screen. Now we're going to print this text and we're going to print it after it had, it adds the hunger. Let's move this a bit down. We can connect all of this to the print string. So instead of making a print string for each of them, you can actually connected. So for example, if it chooses banana and you're going to choose banana, add the hunger and then go over to print the string. So all of these will not be printed because remember the flow goes only one way. It goes this way. Okay, so now we print this to the screen. I'm going to make it a bit compact. Okay, so now it's going to print to the screen. And let's see what happens right now when we click play. So if I compile and click Play, going to say hello friend. And actually let's make, this is the first bug we have or not a bug, but the first mistake, maybe we need to make it a bit longer so we can see what's going on. Just like this. And let's compile a quick play. It's going to say hello friend, press E to eat a random fruit. And we'll press E and nothing happens. And we'll see why that is. It's just because we have never called our eat fruit event. Remember we have to call events before they work. So over here, we have chosen a fruit, but we never go to here. So let's call the event by saying eat fruits. And let's connect everything. And let's compile and click Play again, press E. Now it says young it was a banana, you're hungry meter. Sexually make it a bit longer here. Now it's working. The code is working right now. And I want to show you one more bug. Let's Play and eat. It says Nice, you eat a pineapple Yolngu mirror is now 80. Nice if you want to eat again, press R. But actually like an click E again to eat. I don't need to press R. So we have to fix that mistake. And it's actually not own a stake, we have to add some more things. So here when you press E, Remember a multi gate gives you the option to execute all of these pens. So you can see if I press E, I can press F4 times 1234. And if I click More icon, press anymore. But the Watergate gives you the option to, to play all of these pens. But we just want to eat one banana and we want, or we want to eat one fruit and we want to press R to eat again, we don't want to eat all the time. So let's make a Boolean and call it can eat, change the variable type to Boolean. Well it out. And then say, if you can eat. If this is true. Okay, If you can eat, if this is true, you can eat, then go ahead and do this. However, if you can't eat, then do nothing. So if you can eat, you can go ahead. And so over here, when we eat something, when I click on E and it says eat fruits are actually going to set this to false. Now you can't eat anymore. And default value here should be true because at the beginning of the game, I can eat. So the default value needs to be true. And when we eat a fruit, it's going to be false. So if I try to click E again, it's not going to do anything because I can't eat. This is going to be false. When I go to this event. If I click Play and act like E, Yes, I can eat, but if I click E Again, I can't eat anymore. Okay, So let's make the button. Well, the last thing, the R button if I want to eat again. So this is very simple. We just set the can eat to true and we can actually go ahead and eat again. So let's compile and click Play. It can eat. If I click ie, I can't eat anymore. If I click R and E again, then I can eat it. And you can see I can press R and E again and again. And after that we don't have any more fruit. And that is it you have eaten all the fruit. However, if you want to reset it, you can always set it to loop. Or you can use a custom event to reset and do it that way. So now we have learned about the enumeration. You can also set it to specific values. We use the Maasai gate, we use the sequence. You will learn how to use booleans to actually stop the code from happening until it's set again. And also using this select which is something new and the switch on enumeration. And also how to collapse to a function. And we can actually attach to the variables, to the function inputs. So it appears over here and you can actually add a value. It goes through the code, and then it adds it to the hunger meter. So now the hunger and meters updated and we can print it to the screen. I hope this was useful for you and if you need any help with any of it, please don't hesitate to come and are right in the Discord server or any of our social media. I am willing, more than willing to help you out. So I hope you had fun and let's move on to the next lesson. 41. What are Blueprint Classes?: Hello and welcome to this section. So now we're actually going to go into the more advanced stuff. And this is going to be fun now because this is actually blueprint classes are the ones who are going to work with all the time. And it's also the first thing we're going to work with when we make our first video game. So these, this is going to be fun. Now, we have learned all of the basics, all of the enumerations, execution flows, arrays, events, function macros. We've been through the variables and all of these fundamentals. And now let's talk about Blueprint actors. So to make a blueprint actor, you have to right-click over here and you can create it through here, Blueprint, Blueprint class. And to whom make a glass. You can also go over here and blueprints. And so far we have learned about enumeration, the blueprint macro library, the blueprint function library. And now let's go and dive in into the blueprint of classes. So when you'll click here in the blueprint glasses, you can see here you have different things you can choose from. So in Unreal Engine, you can create different blueprints and you can choose what type of blueprint you want to create. And all of these are essential for us in the game. For example, we have the game mode, we have the player controller, we have the character, we have upon, and we have an actor. So let's go ahead to the next lessons. And in the next lessons, these will be shorts because we will go more in depth with these when we create our game. But I want, in the next lessons, explain to you shortly what each of these are. 42. Actor: So firstly, the simplest Blueprint Class is the actor. And you can see here that an actor is an object that can be placed or spawned in the world. So an actor is not something you control. It's not a character. And actor is just a simple object, US born into the world. So for example, if you have captured the flight mode, you're going to capture the flag. Flag is an actor, so it could also be, for example, a fireplace. So you have a fireplace. So any kind of objects that can be placed in the world and is not an actor, it's not something you control. So for example, this could also be a table that you place things on in the game. So this is the simplest one, and that is what an actor is. 43. Pawn: The next one is a Po1 and upon you can actually control. So a pon is an actor that can be possessed. And what possessed mean is that you can actually control it with your keys, with their keyboards. So AW, DNS and receive input from a controller. And the controller is actually this one over here and the player controller. So what upon is, is actually something that can be controlled. But let's say we wanted to make a game and we actually want this sphere over here. We want to control it. It is our character. We can actually make it into a upon. And we can use our keyboard to move around with this. With the sphere. There is in y, we're not making it into a character is actually because it's not a character looking thing. So we can imagine a character with two arms, two likes. It's not like that, It's just a sphere. And we can use this as upon and upon can receive inputs so we can actually move this sphere. If this fear was an actor, we would not be able to use the keyboard to move this sphere. 44. Character: Okay, so the next one is a character. And a character is a type of pon that includes the ability to walk around. So you can imagine like a character with two arms, two legs that can walk around. And therefore here we would make it into a character and not a pond. And here it tells you that a character is a type of porn. So actually this is a subclass of this. This is actually a, a Po1. And I will explain later on why this is important. It doesn't really matter for you right now. But just remember that characters have the ability to walk. And when you have a characters, for example, a counterterrorist or a terrorist in Counter-Strike, we would make a character. 45. Player Controller: The next thing is the player controller. And a flow controller is an actor responsible for controlling upon, used by the player. Know when I have this point here. Actually this player controller is what controls my porn or my character. So this one is not like a controller, like you have for your Xbox or your PlayStation. Each character that moves have a, have a controller attached to them. So for example, if you have player one and player two, each of these have a controller. And inside of this Blueprint Class is where I usually do the movement. So I use, for example, if you need to use the W to move forward, I usually do it inside of this blueprint. So each, each of the characters that can move around, each of the ponds or characters that can move around. These actually have a player controller and inside of this blueprint, you can do the, the movement. And I actually also do the user interface inside of this player controller. Because each player has to see the interface. And you can do this through the player controller. And I can show a letter on how we can do this. 46. Game Mode: Okay, so the last one I want to talk about is the Game Mode. And the Demode base defines the game being played, its rules, scoring, and other facets of the game type. So this is the Game Mode. You can imagine it if you had a game mode inside of your game. So for example, capture the flag. You have to define how many lives do you have? You have to define how many points do you get for capturing the flag. You have to define how much, how many minutes do you have each round in this game mode and so on. So the game mode defines the rules of the game. And as for the last ones, we won't really cover them for now. But you can also see we have a lot more other classes and these are not important for you right now. Don't worry about all of this. You can see here we also have saved game, so we can make, we can save the game and load the game, but this is too complex for now. So don't worry about all of these classes. Let's focus on these 12345. And then we can move on to more complex classes. 47. What are Blueprint Actors?: Hello everyone and welcome to the section about Blueprint actors. So what a blueprint actor is, you can actually put together several of these items. For example, a cube. You can put it together with a light and it can actually mix different objects together into a blueprint. And then you can use that blueprint took place around in your level to do some level design. And with blueprint actors, you can also do behaviors such as, for example, coins that your character will loot and basically blueprint actors are static actors that is around in your world. So let's go ahead and learn how to create a blueprint actor. 48. Creating a Blueprint Actor: Okay, so here I have deleted everything so we can start from fresh. And let's create our first blueprint actor. So firstly, I want to create a new folder called blueprints. And inside of this folder you can right-click. And under Blueprints, you can find something called Brooklyn Blueprint class. Or you can find it up here, which is a lot easier. So click on Blueprint class. And you can see here that these different classes we talked about. And the first one, the simplest one is the blueprint actor. So let's go ahead and click on the actor. And for the blueprints, we are going to call them BP in the beginning for blueprint. And for this one, let's call it light pole. So we will create a very simple light pole. And let's double-click this blueprint actor. And you can see here we have some sort of a scene that we haven't seen yet. Now inside of this viewport, you can add items, and for example, we can add the bugs and so on. And here we have a Construction Script. So this is programming, and here we can tell the actor what to do before it is, or what you do actually when it's spawned it right away. So here we have the event graph that we saw earlier would the Level Blueprint. So this is cool. Now we're actually networking in the Level Blueprint anymore. Now we are working in an actor. So I would just want to tell you a difference between these two. So the blue, the Level Blueprint is, it's blueprint or programming for this specific level you are in. So if I do something in the Level Blueprint for this level, and I then go ahead and right-click and create another level. Then actually this code that I wrote in this level, blueprint for this specific level is actually not going to be carried to the new level. So you have to have in mind if you do something in the Level Blueprint, and this is only going to be specific for the current level you are programming in. However, if you do a blueprint class, this one can actually be used in all of your levels. So for example, here I have a blueprint class, and this one, you can drag over to the level. Let's say it's because right now it's empty. We haven't, we haven't really added anything to the viewpoint here. So right now it's empty, but you can drag it into the level. And you can do that for all levels. So this is the advantage of a blueprint classes. This is very powerful. And remember, if you do something in the Level Blueprint, this code will be specifically for that level you are coding in. Okay, so let's go back to the view port here. And it consists of this viewport and it can, whoops, I took it out by mistake. So it consists of the viewport and it consists of the construction script with just sells the actor what to do when it's spawns. So this will be fired away instantly when it spawned. And here you usually code things that you want to make sure the actor has done right away before you do anything else. And lastly, the Event Graph. This is just like the Level Blueprint where you write your code and all of that. And this will be this code here in this event graph will be specific for this blueprint actor that you are currently working in. So let's go ahead and create our light pole. And here in the Event Graph, you can see here to the left we have components and we're actually going to talk about components in another lesson. But let's go ahead and add something to it. I'll click on the BP pole or anywhere here and click on Add. And let's add a cube. So click on this cube. You can see here we have added a cube as well as here. And we can actually resize this cube so you can see or if you resize it. And I actually want to open this lock because I don't want to resize it uniformly. And I can also go ahead and use the scale tool. And I'm going to go into the left view just so I can take this above ground. Now go to the right view is looking fine. I'm going back to the perspective. Okay, so now I have some sort of a light pole and actually want to add a light to it. So this is very cool. You can combine things in a Blueprint class. So here you can add again and add a light, a point light for example. And this point lie to, you can check up here. Okay, So this is very cool. And if I compile, save, I save everything. And let me save this level. And I'm going to create a new folder, call it maps. Actually, I already did that for me. Inside of Maps, let me save this and call it let's call it Map Tutorial again. Okay, let me close this blueprint actor and let me delete this new folder I made. So here, this is the light polling made and this is very cool. Now you can see this blueprint actor actually has the cube we added and also the light. So this is very cool. You can combine objects and put them together. Instead of going in here and adding a cube, resizing it. And then you add the light on top of it. Let me add a light. Let's say we did it that way. But then if you needed this slide again over here, you had to go over and create a new shape and so on. This is going to take a lot of time. And actually also for the blueprint classes, we can add code to this class. So for example, if we want to turn off the light, if the player is not, is not nearby, we can code here that we want to turn off the light. Okay, So we can add behavior to blueprint classes. So this is how you create a blueprint class. And in the next lesson, Let's see how we spawn these Blueprint Classes and how to destroy them. 49. Spawn & Destroy Actor: Hello and welcome. So now we're going to talk about how to spawn and destroy an actor. So this is very simple. The first way to spawn an actor if you already know that specified location in your level. For example, if you want to place coins around or you are doing some level design, you can always drag out the actor and place it wherever you want. Just like this. But this is the easiest way to spawn the actor. You can also just hold and hold the Alt while moving and you can duplicate it. Now this is the easiest way and let me go ahead and delete all of them. The second way you can do it if you don't want to spawn it right away when the game begins, you actually want to spawn it during the gameplay. You can go ahead and let's go over to the level blueprints. And let's do a begin play. And let's delay this begin play by doing seconds. Okay? And now we have to use the node here called Bonn actor from class. So now we are going to spawn an actor. And here the class is this one. Remember, this is a blueprint class because when you right-click and create it, It's a blueprint class. This is the actor who created. So this blueprint class, we can find it by searching for the name VP light pole. Ok, and now it's asking for a transformation. So where do you want to spawn this light pole? And a good trick I want to show you, for example, if you want a specified location, for example, if you want to spawn it here specifically, and you want to know the location, can always create a shape. For example, a cube. We can move the cube to over there and try to adjust it. A Gauss. Always try to see those locations and you can right-click and copy this location. And then you can do it and you can place it in the transform. Just remember this is going from the pivot point. So if your pivot point is down here, it will be floating. So you have to take it down. You can see the z value is 0, 1 I reached to here. And this is because it's taking the value from this at that point. Okay, so let me go back to the Level Blueprint. So now we have to specify location, but I just want to spawn it in the middle of the level, so it's 000, 000. What you can do is you can break or a sorry, make a transform. And make transform just makes the transform so you can actually insert those values. What you can do also is right-click do Split Struct Pin. And this will split this truck pen and you can write the values. What I prefer doing is promoting it to a variable. So right-click promoter variable and you can call it whole Transform. I can try to move it down. So now we have a pole transform and if you compile, we can see the default values. And maybe I want the geolocation to be 15. I think this ground is elevated a bit, so not to make it underground. Let's compile and save. And here is the collision. If you have collision you cannot. For example, we can choose tried to adjust location, but always fun if you always want to spawn it. Even though some, something is standing in the way. Let's click Play. And after three seconds, this should spawn the poll. So I'll click play. After three seconds. It's just one the poll. So this is how you spawn an actor into the level. Okay, so now that we have spawned the actor into the level, let's learn how to destroy the actor. So now when we click Play again, it spawns after three seconds, but we can actually destroy this actor if we want to destroy it during the game. And in the case, for example, about coins, if your character walks into a coin, the coin will disappear. And this is what is called Destroy Actor. You're actually destroying the actor. The coin is not in the level anymore because you already alluded it. So let's go to the Level Blueprint here. And let's say after three seconds again, let's delay the spawn. After three seconds again, we want to destroy this actor. So Destroy Actor. And now we have to remember what is the target? The target is this light pole here that we spawned. Okay? So let's go over here. And what you can do here. Very cool is this actor that you spawned. This is what we want to remove again, you can right-click here and promote this to a variable and we can call it light pole. Okay, so now we have, now we, this is the first time we actually made an actor variable. So this is the BP light pole. So we spawn, respond to light pole, and this is actually the light pole. So now we created, promoted it to a variable. So we can actually use it here, because here we want to destroy the light pole. Now you can take this variable listed here. Now it's going to destroy this light pole again after spawning it after three seconds. Well, let's compile click Play and see what happens. So after three seconds it's respond. And after three seconds it should destroy the light pole. Now this is how you spawn and this is how you destroy actors inside of the game. 50. Scene Components: So let's talk about a scene components and who have already created some sin components. So let's double-click the light pole Blueprint class that we created. And inside of here in the viewport, we added the slide and we added this cube. So total left we have something called components. And here you can add all of the components you want. This is actually the scene and all of the components you add to this blueprint so far, for example, a sphere. And want to move this fear around, I duplicated the sphere, or actually let me duplicate it from here. And I can move it around and let's say it's over here. And compound Save, you can see that over here, this is actually consisting of all the elements I put into the scene. So this is very cool. You can design some cool stuff. For example, if you're designing a coin shop for your game, you can design the house. You can design the, the wooden sign. You can design the light around it or whatever you are a sharp consists of. So your shop doesn't consist of one element. You can actually just put elements together and make the shop as a whole. And then you can drag this out to the level and this is pretty cool. So these are the Blueprint Components, and these are components that you can add to the level. And you always have a root here, which is the just the default starting component, and can always replace this route by dragging wherever you have on top of it. And now this becomes the root. And see this is bit messed up. So we can always choose what to make your roots of the Blueprint Class. Okay? And now we can't really move this around. This is the blueprint route now. And if you want to move it around, just control Z and let's undo what we did. So you can add more stuff to your, add more components through this Add button. And you can actually add a lot of things. For example, audio, you can add sound. You can add a skeletal mesh. We haven't touched that yet. You can add cameras, you can add collision boxes. Our trigger boxes rather. And you can add was called visual effects and a lot of other things. So you can build up a whole scene here are just for this element. For example, another use of it is I had a fireplace, and this fireplace consists of a lot of logs and the fire effects in the middle. So I had to build the logs here around. And you can build the the fire effect in the middle. And after you build it, you can drag it out and put it in the scene. So these are the components. Just for fun, you can always click here an ad and see what happens. And the scene component is just a, an empty component here. So this is an empty one. This will not do anything, but, but the sin component, it has transformation so it can be attached to other sink components and you can do stuff. And you can try to click around, click different shapes, try to add it and nothing happens. You can always delete it afterwards, right, to add collision boxes, see what happens. So play around, and these are the same components. And let's talk about editable variables and exposed on spawn. And the next lesson. 51. Editable Variable & Expose on Spawn: Okay, so let's talk about the editable variables and exposed on spawn. And what an editable variable is, you can actually make the variable editable and expose it here. So for example, this is very useful for designers. Let's say you took out the slide poll. And actually you can expose variables in such a way that you can edit them here to the right. So let's say for example, if you wanted to change the color of the light pole to read, instead of going inside of the blueprints and changing the code and making it red, you can actually expose the variable that's controlling it. And you can change the color here to the right. Can see this is very useful for people who doesn't know blueprints at all. They can just go ahead here in the Details panel and change whatever variable you have exposed. And maybe this is, this is actually also useful for programmers. If you have something, you want to change it here and it's more convenient. So let's go ahead and see how this is done. Let's do something to this light pole that we created. So let's double-click on it. And in here, Let's make two variables. So the first one is a boolean, and let's call it intense lights and the ten slides. So for example, we want the light to be intense. If this is, this is set to true. And let's make another one called lights or shoved description. Let's present this light pole is in the coin shop and you have to read the description and people will read the description and buy it. Okay, So this is a text, so this is a description. And let's compile. So now have these two. And what you do is you click on Instance editable. So we're able to edit it and you are, and this is being exposed on spawn. So let's do the same with the text variable here, and let's compile and save. Let's actually put it out here. And you can see now you have these values. So intense light, we can take this, this was the Boolean and this is the description, for example, this is the first light, light pole in the world. In the world. Okay? And the cool thing about it, you can change it independently. So now we have added a description for this. And you can actually do something else for this one. Okay? Now this is very cool. You can expose variables on spawn and you can actually edit them out here instead of going in here and doing something with the code. Okay, so I wanted to show you some stuff we can do with this. So let's do the Begin Play. And let's do, let's take this intense light. And let's create a branch. And if this intense light is true, let's take our point light, which is the component here, which we have. And these components will be down here as variables. You can see we have components. So this is the point light. And we can do intensity. And then you see something called set intensity. So now we want to set the intensity. Let's set it to 50, and let's also change the color. This will be a lot more visual. So let's write color and you see something called set light color. Let's take this up here. And let's change the color to something we can see. For example, like this. It's actually do it very horribly just like this. And now we change the color and the intensity. And if nothing, if this is false, we can just set the intensity to one. Okay, so now we need a target for this. So drag out the point light and connected to this intensity Compile and Save. So now this intense light is ticked. We are going to set the intensity to 50 instead of one. And we are going to change the color. So let's see how this place, let's minimize this and I'm going to delete one of those. Okay? And then the Level Blueprint. Remember this is what we did before in the previous lessons, we delayed with three seconds. We spawned an actor respond to light pole and the middle of the map. And then we delayed and destroyed it. Let me actually remove this destroyed now so we can see it. And like replace this one over here. And the other one was spawn, spawn in the middle. And let me go over and reduce the light source because we want to see the lights. I'm going to write 0 here. And another thing that's annoying, our exposure is being affected. So let's go over to create visual effects, do a post-process volume. And here under exposure. And now we have this post-process volume here. And underexposure. Take the minimum brightness and maximum brightness and put them to one. And also remember, this does not do anything if you don't go to the bottom and do the infinite extent, so it affects the whole map. Okay, So now the exposure is not being adjusted when we move around. Let's save everything and let's click Play. Now you can see these look the same. Let's go back. If we click this one and we go up and click the intense light, now it will change color and have intense light. Let's click Play again. I can see here it has intense lights. It needs to be more intense because we can't really see it, but you can see the color is red while the other one is not red. And this is because the one that spawned does not have the will go back, does not have the intense light ticked because by default it is not ticked. So by default it's false. So those are the ones that respond is as the intensity of one and the color is default. While the other one. We have ticked has the red color and has the intense light. So this is how you spawn variable or exposed variables to spawn here in the Details panel. And very useful again for artist who doesn't really know any Blueprint. And you want to put out the variables for them here. And the last thing I just want to show you here, you can see it's under default currently. You can change this by going inside of the variable. And this is regarding the category is default. You can change it to something else. For example, I can make light pole here. And the same thing with the description, you can call it light pole, and they will be under the same the same section here. This is also good for organizing your code. And if you compile, you can also see that now they are under the light pole heading. All right, Let's move over to the next lesson. 52. Overlap Events: All right, so let's talk about overlap events and what we can use with overlap events. You can imagine your character is running into a, an item you can loot and take into your backpack. This item will be destroyed and looted. And for this to happen, you have to have some sort of an overlap event and detect that your player has alluded the coin or whatever item you have. Okay, so let's do this with this light pole we have, and let's double-click it. And over it in the components we can add something called a trigger bucks. So click here and let's go down. And you can see here we have Box Collision, capsule collision or spherical lesion. So with this we can do some sort of overlap event solos. For now let's use this box collision. This will be perfect for us, okay? And for this, usually I call, I call it trigger bucks, but it doesn't really matter what you call it. Can also call it a collision box or bugs collision. And let's delete this for now. Okay, Let's compile and save. And let's place our light pole here in the middle. Let's turn up the light. I turned it down in the last lesson. So let me put it up to three again, just like what we had it before. And now let's go over to the viewport. Click on the trigger bugs we made. And now you can rescale it either here or we can rescale it over here in the bugs extent. Okay, So for example, I can Control Z and you can see what happens here in the box extent. You can also resize it and doesn't really matter. But when you make the game, it of course has to be specific. Like it has to be accurate. But for now this is fine. Let's say this is very accurate and Compile and Save. And now we have a collision box and we can do some stuff with it. Well, let's go over to the Event Graph. And here, instead of doing the begin play, we want the, the collision events or clicking on this. Or actually you don't really have to click on it, but you can find the events faster. You can see here at event for a trigger bugs and collision. And you can do the add on component, begin overlap. Or the other thing you can do, clicking on the Trigger box, going down to the bottom, you can find all of these different events. If I make this a bit bigger, you can see here something called on component, hit on component begin overlap. This is what we're going to use, and component and overlap and so on. So instead of going in here making a new event, this is a lot faster. And just click on the trigger box or the Box Collision you made. Go down to the bottom and hit the beginning of a lab. Okay. And before we do anything else with the overlap here, let's go over and create a cube that can move and then hit this collision box. And when it hits this collision bugs, we can do this code that will fire when something has hit the collision box. Oh, we can move this away. This is the post-process volume. Don't worry about this. This is the component that we have and we're also we can see the Trigger box around it. So let's go ahead and create a new bugs. So go ahead and click Create Shapes, a cube. Let's move it over here. And then what we want to do is just like before we want to set the location of the box every time we press R. So let's go over to the Level Blueprint. And inside of here, Let's use the keyboard to move our you. And remember we have to set this cube to movable in order for it to work or else it will not move in the game. Let's go back to the Level Blueprint. And every time we press R, we want to move the cube by 20 in the x-axis. And the way you know in what axis you want to move it as because we want to move this way and hit this light bulb, light pole. And this is the red pivot point here. And the red means the x-axis. You can see here the x is read the why is green and the z is blue. So we want to subtract or go in the minus x. Can see here, the x-axis is going to the minus k. So this is the direction we want to move. It was opened up blue frontier Level Blueprints. Click on the cube, right-click here and make a reference to this cube. And you want to get to the actor location. We want the current location of the box. And with this location, let's break the vector. We only want to affect the x-axis. So with this, we want to subtract 180 every time we hit the R key. And then let's make the vector again. Whoops, make a vector. And let's connect the y and z. So now we have the vector again. And let's do set actor, set actor location for this cube. Okay, so now we can set the actual location and we can plug in this new vector value login, connect the archae here. Okay? So this is what will happen when we press our, every time I press R, we are going to get the current location of the cube. We're going to subtract 20 in the x-axis, so it moves by 20. And this is the new location that we will set for it. Okay, So here a cool thing. You can either do it this way for the cube on the targets or you can connect the same thing over here. And you can create a node that's all up to you. Whatever you think is mostly clean. I usually use the same. If it looks clean, if not, if it looks messy, I will just make our, just make a new reference here and connected instead, this is just the same. Okay, let us use it that way. So let's compile click Play and see what happens if we click our working. Every time I click, it's going to move. Okay? So now we need to make it work. So when it hits this collision, when this box hit to this collision box is going to do something. And remember, we have to do overlap events. So click on this box and remember that we need to take inside of the collision, generate overlap events else it will not generate anything. So if this hits this without the collision of a live events hit here, nothing will happen. Remember, ticket, make it true, generate over live events. Let's move it back. Let's save everything. And let's go back to the light pole here. So simply what we want to do when we begin overlap, Let's just print out a string and seeing self destruction. So it's going to destroy itself. And let's delay it by two seconds. And let's destroy the actor. Okay, so let's destroy the actor. And what actor do we want to destroy? You can actually just let it be like this, because self, the target is self. And what does self mean? Self is just this actor that we are in currently. And you can see here we are inside of BP light, light pole. And this is what we want to destroy. So you don't really need a target here because it's self. Is this target the light pole we are destroying? This is all cool. And let's go over and check out the scope. So let's compile, save and click Play. And let's click our move inside of this box. And when you go inside of the collision box is going to say self destruction. And after two seconds it's going to destroy itself. So this is how you do overlap events. And this is pretty cool for when you're loading items, you have to you have to destroy the item after you've loaded it. So it's not appearing in the level anymore and so on. Let's go over to the next lesson and I'll show you a node called actor has tag. 53. Actor Has Tag: Okay, so let's talk about the actor has tagged node. Let's go back to the light pole. And here we can actually choose what kind of actor is going to overlap with our light pole. Imagine you have enemies in your level. Let's say you have these different enemies in your level. And these enemies also walk around. And sometimes they hit the item you want to loot. For example, it's a weapon in the ground or a coin or whatever. And when these enemies had the coin, they are actually overlapping with this Trigger box and it will trigger this event. But this is not what we want to do. We only want the player to hit this Trigger box. We don't want, we don't want the coin to disappear when the enemy hits the coin. Okay? So this is where we can use actor has tag. So in the other actor, this is the actor that, that is overlapping the component here. This is the player. Here we can write actor has tag. And you can see here a function called actor has tagged. And we can write a tag here, for example, we can call it player. Okay? And this tag is actually set inside of these actors. So in this box, can go over to the search details. You can find it down here. But instead of finding X, you can also just write tag. And you can see here we have something called an actor tag. And you can click on plus and you can actually actually add a tag to this actor. So for example, you can call it player. So now this actor actually has the tape player. And if there are other, it, it means walking around and they don't have this tag. This is not going to be fired. Because now we're going to say, if the actor has the tag player, if this is true, then go ahead and self-destruct. But let's compile and click Save. And let's press our walk into this. It's going to say self destruction and is going to solve the straw. However, if the tag was not player, let's just call it enemy, for example. And then click Play. I'm going to click are. And when it hits, It's not going to do anything because the tag is not player. Now this is very cool. You can actually control what triggers this box or triggers this event. So if the, if the actor has another tag, if it's not Claire, for example, and you choose whatever you want to call the tag. And usually this is used for players. When the player hits this item, it's going to do this kind of code. If the enemy hits it, the enemy who does not have the tag player, nothing will happen. So this is very useful to use in cases like this. 54. Get All Actors: Okay, so before we end this section, let's talk about the Get all actors of class. So let's go over to the level blueprint and let's do a begin play. And here we can drag out and do gets all actors. And you can see here we have different functions. We have get all actors of class. We have the one with tag, we have ball. Get all actors with interface, get all actors with tag and the tag. Remember, for example, we have the tag called player. And he's going to get all of the actors inside of this level with the player tag. So this is very cool and it will put it into an array. Remember when we have this square, this means this is an array. So now we have all of these actors would detect player, let's say, I think this one's still has, Let's try layer here. And if we had multiple and all of them has detect player, it's going to put all of these three boxes in this array. And again, remember we can to just access stuff just by writing it here, we have to use the array functions because this is an array now. And you can find the array functions under the utilities and array. And you can add to this array, you can also find item, you can get the item and you can feel the length of this array and so on. Okay, so for this, let's just do get all actors of class just like normally. And let's do the light pole. So choosing the light pole, Sometimes my eye letter is not working and this is getting annoying. Okay, so now we get the light pole and it's going to get all of the light poles in the level. So let's place four of them, for example. Just like this. And let's delete these two for now, four of them. And in the Level Blueprint, Let's do gets. So now we're going to get a one of the light poles. And the one we're getting is number 0. So the first one. And with this, now we can actually, now that we have gotten declares the light pole, we can actually access the components inside of this blueprint. Because now we are inside of this return value is the light pole. And you can actually access, for example, the point light. So if we go over here and write point lights, and the variables are always at the bottom. So if we go to the bottom and we can do and get point light. Because now this is actually the light pole that we have got through here. And we can always do set slight color and do this and change the color to, for example, red. And you can always do, make it very annoying. So we can see it's like this. And remember to connect it to the function here. So now we have the get all actors of class. We're getting the light pole from the array. And we are now accessing the point light. And with that, we are setting the color to red, the Compile and Save and hit play. And you can see here in the level, we've got the first light and we've changed it to a red color, while all of the others have the default, the default color. But we can also do for fun to change the color randomly between these four lights. We can actually, for example, just go here. And instead of just calling the number 0 light, we can do random. So write random. And you can do random integer. So the maximum, you have to specify what the maximum amount of lights there are. And we can actually drag out of this array and do last index. So this is the last index in this array. So if we put more lights here, it's going to note, it's going to know that the last index will be this number. So we don't have to go in here and do four lights. And if we add five more lights, we have to go over and say nine lights and so on. This will calculate automatically because this is always getting the last index of this amount of actors that we haven't level. So connected. Now we have, Let's actually make it a bit better to look at that. We're getting the, the last index. We're getting a random integer from that last index and we're putting it into the get. So now we're getting a random light. We're getting a random point light from this and we're setting the color. So if we hit Play, me go over here. If we hit play. Now, this color, let me see which one if I can see it, this color here is read by county. Hit play again. Now this color is R. This slide is right, so it's going to change color of a random lights. Now this one is red. And now this one is right. But sending a random lights to the red color. So this is how you can use gets all actors have class, it gets all the actors inside of the bone level. And you can specify what kind of accurate is. It could have been. Everything else. It doesn't really have to be this light pole. Imagine if we had more blueprint classes, we could have called all of these other classes. 55. What is Blueprint Communication?: Welcome to this section about Blueprint communication style. What Blueprint communication is is when two different blueprints communicate with each other. And what that means, for example, if we create another blueprint here, another Blueprint Class, we can actually call events from this other Blueprint Class. And then new one we created. We communicate between these two different blueprints. And this is a very important concept because imagine you have different blueprint classes. You have a coin shop, you have a salt shop, and you have your main character, and you need to access different information between these different blueprints. And so you have to communicate between these blueprints. For example, in this blueprint class over here, you have to use an event which is over in the other Blueprint class. And so you have to use communication. Beginners usually think this is the most difficult subject of all of them. One, learning blueprints and I'll try to explain it as clear and best as I can. And also, if you don't understand it too well, try to watch the video again. And we will also try to create our game after the section. And when creating our game, we will also use Blueprint communication, but let's take it one step at a time. And in the next lesson, let's learn about casting. 56. Casting: Hello and welcome to the first lesson about Blueprint communication. And in this one we are going to talk about casting. So now we are trying to communicate between two different blueprints. So firstly, let's create two different blueprint classes so we can communicate. And for this first one, let's create a blueprint actor. And let's call it BP barrel and double-click it. So this will be a simple Beryl here in the components. Let's add a cylinder and let's move it above the ground so it's not beneath the ground and we can scale it just slightly. So it looks like a barrel. Okay, so this is fine for now. We're not really going to design a whole lot. I want to focus on programming, so this is looking fine, okay? And the next thing we want to make is another Blueprint Class. And let's make a game mode. So remember again, mode is where the game rules are defined. I'll click on the game mode and let's call it g, m. This is what I usually call game modes, GM and from the beginning. And I usually call them the game mode type. For example, Capture the Flag if it was captured a flight. But here we don't really have a game mode or we don't really have a game. So I'm just going to call it Demode. Let's save everything. And inside of this game mode, we're not going to add anything here. We are going to go inside of the event graph. And inside of this game mode. Let's do, let's delete these and let's make a custom event. So we want to spawn this barrel. So let's make it a custom event called spawn barrel. And we simply want to spawn actor of from class, which we already did in a previous lesson. And we want to search for BP barrel. So now we are going to spawn this barrel, and we are going to spawn it in the middle of the map. So you can say, you can either promote this to a variable or you can go ahead and drag and right make transform. And we can just do them make transform for now. And I'm just going to write 15 in the z-axis, so it's not beneath the ground. And x and y is 0, so it's in the middle of the map. Okay, So this is very simple. We are just going to spawn the barrel. This is the logic for it. And remember we have to call this event somewhere else. It's not really going to work. Because when we click Play now, nothing really happens. And that's because we have never called this spawn barrel. Ok. And now this is in the game mode. Let's go over to the Level Blueprint. And inside of here, let's do a begin play. And what we want to do, we actually just want to access this game mode so we can spawn or so we can do this are called this event and spawn our barrel for inside of it. Begin play, let's say, let's do print text or print string and say spawning Viral now, unless delay it with three seconds. Now, we want to call this event to spawn this barrel. And how do you access this event from over here and there, and the level blueprints. And the way you do this is with casting. So this is what we're trying to do and how we're trying to communicate with this blueprint class, the Game Mode class we made. So in order to do this, you have to, you have to see what is the general class of this. This is over here in the parent class and the top right. This is the Game Mode base. So this is the base class. And here we can write gets game mode. So now I have this function and now we are getting the general game mode. This is not this game mode that we made. It's not this game mode. This game mode we've got here is just the general game mode. We have to cast to this Custom Game Mode that we made. Because right now this is not the Custom Game Mode. So what we'll have to do is say cast too. And you can see we have this GM game mode, and this is our game mode. Now remember we have to have an object reference. We can't, we can't just say delete this and say cast to GM game mode. And here it is, and Compile and Save. And now it's going to say error. We don't have an object here. What is the object? And the object is the parent class that it's referring to. So in this case, this is a game mode class. And we have to say get Game Mode. And then we'll have to say what game mode do you want to get? We want to get our Custom Game Mode, which is called GM game mode. So let's compile and save. And now it's not saying an error anymore. And now we have got the Game Mode and we've caused to the Custom Game Mode that we made. Down here we can actually now access anything that is within this game mode that we made. Okay, So now if we had different variables, we could access them. In this case, we want to access this custom event. So this one is called spawn barrel. So over here as GM game mode, we want to access these form a barrel. And now we're going to call this spawn barrel and it's going to spawn. Okay. But now it's not, it's not going to spawn because now you can see here if I click Play and I look at the map and it's not going to spawn. And this is because the map we are inside of is currently using the, the normal game mode. So we have to go to the World settings here to the right. And inside of this wall settings we have something called Game Mode override. And this is what we want to change because we are actually want to use our GM game mode. We don't want to use the, the general one, which is actually this one we have. And we want to use our custom one. And this is also what we're going to do when we create our game. We have to change the game mode. So changing the gamma override, we have to change it to our own game mode. And that is it. You can just click Play. And you can see here it says spawning barrel now and after three seconds, so two seconds, so what we added, it will spawn the barrel. So this is very cool. We haven't really used a, we haven't used a spawn actor from class here. We just referred to the Game Mode. And inside of this game mode, we have this custom event, which has the logic to spawn the barrel. So this is how you use casting. And also imagine if we right-click here, made a blueprint class and we actually made a character, for example. The way, for example, if you had a custom events inside of here and you want to access them, Let's say you want to access them here. You have to say instead of saying good game mode, because right now this is not the game mode anymore. The parent class is character. So what you wanted to say is gets player character. And from this you can cast too. And right now this is one is called new blueprints. So this is the one new blueprint and this is how your cost to different blueprints. And let's say I made a variable inside of here called hello and Compile and Save. So now inside of this, when I have, when I have referenced this new blueprint, I can actually write hello and I can see this Boolean, and this is how you use or how you reference different blueprints. So this is how you communicate between blueprints and access their custom events and access their variables. I hope this was not too difficult and if you're confused about some of it, please write to me in the discussion, right to me in private or write in the community discord, I'm always willing to help you out and if you need a better explanation on something, please, right. So so I can better the, the videos I make. And with that, let's go over to the next communication method. And this one is called Blueprint Interfaces. And this one is actually the hardest one for beginners. And let's take it one step at a time. Let's go over and learn about the Blueprint Interfaces. 57. Blueprint Interface: Okay, so now let's talk about the Blueprint Interfaces. And this is what I mainly use when I programmed my games. And there isn't, is, is that casting when you do cost to other blueprints, this is actually creating a hard reference. And when you create too many hide references, for example, if you cut this Blueprint casts to this blueprint, which again costs to the other blueprints. And you keep casting and casting and casting. At the end, it's going to affect performance because this is hard referencing and you are going to low load all of these costs before you do the thing you want to do. In order to do this. Also, when you use Blueprint Interfaces, it's a lot more cleaner on your code. So it's not only the height references, but your code is so much clean. So I recommend do you learn this right from the beginning before you program anything? Because this is so important for you to learn. And let's go ahead and see what Blueprint Interfaces are. There'll, before we create a, create a Blueprint Interface, Let's go ahead and create a blueprint class. Let's make the barrel we had before, what's called BP barrel. And let me go ahead and create this component and cylinder. And I'm going to create the barrel that we had before. Okay, so now I have this barrel. And again, let's go over to the blueprint level blueprint. And let's also open this barrel. And what I want to do is here it can just say in the beginning play, it can print a string and say, I have spawn. And this lasts for ten seconds. And what we want to do inside of the Level Blueprint here, we actually want to spawn this barrel, okay, and so we need some spawning logic. So let's go ahead and create the game mode again, right-click Blueprint class and create a game mode here. And let's call a GM demo. Let's go inside of this game mode. And just like before, let's create a custom events. And this one is going to be called spawn barrel. And let's go ahead and do the spawn actor from class who's the barrel and may transform. And here we are going to write 15, so it's above the ground. But now we have this bonding logic for the barrel. Now we need to call this event for it to work. So we are going back in the Level Blueprint and we want to call it here. So in the begin playing, when we start playing the game, we are, let's, let's delay it by two seconds or three seconds so we have a chance to see it. And let's call this event. So remember before when we had to access it, we wrote delta game mode. Then we wrote caused to GM image. This is what we did before. This is, this was casting and here we could say spawn viral. But now this is not what we want. We're trying not to do hard referencing for now. I actually never used casting unless unless I I have to like, there are some situations you don't want to go to the hassle and make a Blueprint Interface if you're only going to cost once, that's all right, you don't it's not because you're not allowed to use casting. Just be careful not to spam it everywhere. Okay, so instead of using casting, we want to do a Blueprint Interface. To create a Blueprint Interface, I'm actually going to create a new folder inside of blueprints, and I usually call it interfaces. And inside of here, I can right-click. And inside of blueprints, there is something called Blueprint Interface. Okay? And this is pretty cool. We have, so far we have learned about Blueprint Classes, the library, function library and macro library and enumeration. And now we're learning about Blueprint Interfaces. So you almost have all of these. You only need the structure left. So let's do the Blueprint Interface. And for interfaces are usually call them int and then give it a name. And for this case, I want to call it game mode. And you will see why I call it game mode, because this is the interface for the game mode we actually created here. Okay, so if you double-click this Blueprint Interface, you see here we have now this viewport over here. This looks like the Event Graph, and we have a lot of functions. So here in this, in the Blueprint Interface, you create functions and these functions you use in other blueprints. So this is like a function holder. Okay? And this is, the Blueprint Interface is specific for blueprints. So I will see how I will show you how you attach into those. Okay, so let's try to, instead of doing the casting, we actually want to avoid casting and we want to reference this game mode without doing casting. So how do we do this? First off, inside of the game mode, here, in the interface game mode interface, we are going to make a new function called set Game Mode rref. And this is like setting the game mode reference, okay, you can call it whatever you want. But this makes sense for me, said Demode ref. Okay, So this function is specified to set the Game Mode reference. And here in the output, we're going to add a variable. Okay? And this one, you can actually write game mode. And you can see here I can find my GM game mode. This is the Game Mode class that we made here. Okay, So we want a reference to this game mode class. So right, game mode and find the one called GM game mode. This is our game mode. And this should be an object reference. And let's call it game mode. Okay, So this is a variable, this is just like reading a Boolean or an integer. But here the variable is our game mode class. Okay, let's compile and save, and I'll show you how we can access this. So inside of the game mode, the, the class that we made here, we have to go inside of here. And inside of the, you have something called Class Settings, and you have something called class defaults. Okay? So inside of the class settings, you have something called interfaces. You have to add the interface to a blueprint before you it can work. So right now this, this interface is not attached to the game mode, and therefore it will not show anything. We have to attach it to the blueprint. We want to use it in. And in this case, we want to use it inside of the game mode. So here we click on the ad and we search for the interface or int. And this is why it's so good to write names before the actual name. So click on the end game mode. And now we have added it to remember to compile for it to work, compile, save. And you can see here to the left something appears. This is the interface. So now in the interfaces, all of the functions you make here will appear here. Okay? So now you can double-click on this game mode or a dysfunction you made. You can see here this is actually the function you made here. You can't do anything here, you can't add stuff here. This is just the interface. You can only create the function and you can use the function inside of this blueprint when you add it to the class setting. So remember, a lot of people make the mistake of forgetting to add the two at the interface here. So remember to edit. And after that you can actually access the function. And here we can see the reference or the variable game mode. And the way we reference this, we can actually just write self. So we are going to say the game mode. What is, what is this reference? So what is, what is this game mode reference? And this is self, because self, we are inside of the game, gm Game Mode. I remember this variable. This variable is GM game mode. So this is actually self, this is itself that it's referencing. And now this is very cool. So now I'll show you what the actual result is inside of the Level Blueprint that we were in. Instead of doing the get Game Mode and then casting, we can actually now access this this interface function here. So going back to the Level Blueprint, we can say set Game Mode ref. And you can see here we have SET game mode ref, and it's very important that it says message. And this means that this is the interface. If it does not say message, this is wrong. Okay, so remember to read that it says message. And there should be a letter icon up here. So this means that this is from an interface. And if we hook it up, now we have a reference to this game mode, because this game mode, we have referenced it to self. So it knows that this game mode here is actually this game mode. Discuss them Game Mode we made. If you didn't hook up anything here, it wouldn't, it wouldn't really know what, what does variable was. So self means this game mode is actually this game mode we are in. And as this game mode, we can do the spawn and barrel, okay, So we can do bond barrel. So this is how you work with Blueprint Interfaces. So now we didn't cost. And this is pretty cool and you can see the code also becomes a lot cleaner. If we, if we save everything, they've everything. Remember to compile. And let's click Play and see what happens. We have to go inside of the world settings and set the GM game mode, which is our custom game mode. And let's try to play again. And you can see here after three seconds, it's bonds are barrel, OK. So now we actually spawned a barrel with, without doing the casting. So this bag go back and I'll explain it one more time Just quickly. So what we did is we created this Blueprint Interface. So this is our Blueprint Interface here. And you have to attach Blueprint Interfaces through the class settings. So I could have, I could have added it here if it made sense, but this was only created for the game mode, so it only makes sense to add it here to the game mode. And when we added, we can access the interface functions. And inside of this function we made, we actually just want it to reference this game mode. So we added a variable, and the variable was this GM game mode. So inside of GM game mode, we access this interface we made and we have to specify to it what is this variable? This is self, because we are already in GM game mode. So this is how you can reference to. And inside of the Level Blueprint, we can then get the game mode. This is the general parents game mode up here. And we can call then the set Game Mode ref. So you can actually access now these Blueprint Interface functions. And then you can call the bond barrel because we already know that this game mode, we have referenced it as self over here. So it knows that, that you mean GM game mode over here. Now let me show you another cool thing before we end the video over here in the indie game mode, instead of doing a spawn barrel custom event, I will show you how to do a, an event through the through the interface. Here I'm going to delete this spine barrel, OK. And I'm going back to the interface, and I'm going to add a function and call it spawn unbearable. Okay, and the important thing to know here is if you create an output, if you double-click this and said Gamow drove. If you click an output like a return node, this will be a function, okay? So this will be a function and it will be blue. And you can see it here. However, if you make a function without an output, so it is, It is only the input here. It will be an event and this will be yellow. So events are yellow, okay? And it will be an event if you don't have an output. However, if you have an output or return note, it will not be an event at will be normal function that you can access. However, if it's a, if it's an event, it means that you only have an input here and you can double-click and access it because this is an event. So we have an event called spawn barrel, and we can actually go to the game mode here and write spawn barrel because you can't drag out here. It says error, you can't drag out. So you have derived spawn about what you are looking for is this event spawn barrel because you are, you need the events, so events mambo. And you can see here that this Icons means this is from an interface. So now you can use this here and plug it in. Okay, so now you have an event using the Blueprint Interface. And, and the reason why we can call it is because we have added it to the class settings. So it knows all of these functions we add here. So you can use them here. And this is a lot cleaner that you can add all of the functions here and then use them. And the way we call the Now we're getting an error because this is not the custom event anymore. We need to change it. This is now the Blueprint Interface Event, and this one is called spawn barrel. So we're going to write spawn barrel and the one we need to choose is remember, it's this message. So this is the front, the Blueprint Interface. So spawn barrel, we're going to call this one. What we are going to do is we're getting the game mode. We're getting the reference, which is referencing to this GM game mode that we made. And from here we are, we are calling this Blueprint Interface, which is the event that we made inside of the interface over here. So we made the spine bell. Okay, so that's pretty cool. Let's click Play and see what happens. And after three seconds, it should spawn that as well, which is legit also does. So this makes the code a lot cleaner. And you will see also more clearly when we make our game because I will use Blueprint Interfaces so we can practice. And also remember that you can add inputs to these events. So for example, let's say you needed this, this spawn transform inside of this event could actually go in here in this point barrel. And you could add an input and call it spawn transform. Actually make this a little bit bigger so you can see what's in there. So I can call it spawn transform and I can make it into a transform variable and I compile. And if you go back to the game mode, you can actually see now we have a transform and we could, for example, have plugged it into here. But right now this doesn't make sense because we, we aren't referencing it here. So you can see here if I compile and save and go back to the blueprint, the Level Blueprint. You can actually do it that way and you could add a transform here. And let's say we wanted to, for example, get, get word. The actor is standing. For example, if you had a character, I would get the character's position and I would plug it in. And when I plug a position in here as just a promoter variable. And you can see, so this variable over here is going to go ahead and put this input inside of this, inside of this event or this function over here. And it will go through to here, and it will put the, whatever you add it in this variable, it will be added to this spawn actor. All right, so this was it for the Blueprint Interfaces, and we will use it a lot more when we create our first game. And before we create our game, Let's go ahead and learn about, about the last thing, which is the event dispatchers. 58. Event Dispatcher: Hello and welcome back to this last one in the Blueprint communication. And this one is about event dispatchers. So this one is a bit different from Blueprint Interfaces. The event dispatchers focuses more on firing multiple events. And you can fire one event, you can find multiple events. And the cool thing is you can also communicate with the Level Blueprint over here. And instead of explaining it, Let's go ahead and do an example with an Event Dispatcher. So here in the blueprints, I want to create a new class and this one. And let's say I want to create an actor and let's create the barrel. So we want to spawn the barrel at a certain time. But we'll have this barrel. We can add a components cylinder like we did before. Okay, Just like this. Now we have this barrel and here we also want to create a player controller. So right-click Blueprint class and create a controller. And for plug controllers, I usually call them PC. And let's just call it player controller. Okay, So inside of this player controller, the idea we want to do is when you press the key on the keyboard, you gain coins. And when he gained enough coins, you will spawn this barrel in the map. Okay, and we want to do it through a, in an Event Dispatcher. Now we're going inside of the player controller and we don't do anything in here, must go over to the Event Graph. I want to delete these events and less strides E keyboard here. So now I have this Iike and we want to gain coins when we proceed. So let's make a variable, call it coins. And this one is an integer because coins count doesn't really have decimal places. That doesn't make sense unless your game has integer. We just want ordinary coins. And when you press the E key, we want two plus by one coin. So on a precedent key we want to plus, plus by one coin. And when we have enough coins, we want to spawn the barrel and we want to do that logic inside of the Level Blueprint. So let's go over and open the Level Blueprint. Remember to be inside of this map tutorial. Okay? And in their Level Blueprint, Let's go over and say begin clay. And what we want to do, we want to call to the dispatcher. So now let's create the dispatcher and also come back to this level blueprint. So over here, we want to create an Event Dispatcher. Okay, So credit on this Plus to make an Event Dispatcher and we can call it barrel spawner. Okay, So this event dispatcher we can compile. And to the right, you can see we have something called inputs and we can add a parameter. So let's go ahead and do that. Click on new parameter. And for here we want to add these coins so I can drag it out and you can see what it, what it looks like. And if you drag it out, you can see you can call it a combined it on bandits and event and sine. A sine. And this is what it is. You have to call this dispatcher. This is just like, this is just like calling this function or doing it with the user interfaces. This is what you do with even dispatchers. You call it, okay? And you connected just like any other function. Okay, so now we are calling this event dispatcher. And let me go ahead and do this correctly with the variable over here. So if you click on the Event Dispatcher down here, Let's change the variable to integer because we want this coin value. And you can just call it coins. Compile and Save. And let's actually delete this one and drag it out and collagen. So it's correct. And let's connect this integer result and sort of coins. Okay, so now we have called this Event Dispatcher, just like when you call events, okay? Just like when you call events normally. So now I have this Event Dispatcher and let's go over to the tutorial or the Level Blueprint. And here we want to access this Event Dispatcher. And remember, if we want to access anything inside of this custom Blueprint Class, we have to either a cost to it or use Blueprint Interfaces. So for this one, I can show you how to do both just for practice. If you want to cost to it, you can say git player controller. You guys remember, the parent class is the player controller. And this is the general player control law. But here you want to cast to your own custom controller, though, right, Class 2. And you find this controller. And from here, you can then call the Event Dispatcher. And when you want to call to an event dispatcher, you have to bind it. This is what it's called. You bind to the Event Dispatcher. So you're right by two. And then you write the name of the event dispatcher. In this case for us, we called it barrels fauna, and you can see here it says Bind Event to barrel spawner. I'll explain this one and I'm a little bit, Let's go ahead and see how we can do this inside of a Blueprint Interface instead of costing. So you have the two options just for practice. And let me delete this again. And let me go over and make a Blueprint Interface. Firstly, we have to get a reference to this level controller. So the way we do it is let's go over in the blueprints, creating a folder. All at interfaces. Inside of this, let's make a new interface instead of blueprints and Blueprint Interface. Let's call it int lab Controller. And let's double-click. And inside of here, Let's make a new function called That's lay up controller F. And you can call it whatever you want. And we want a reference, reference to this player controller. So let me show you here in the lab controller. Remember we have to add interfaces to glosses else they will not work. So inside of the class settings, you have two down here and the interfaces, you have to add the ENT black controller we just made. I'm going to do it. You can see here our interface function appears. Okay, remember, this is a, this is an event if we only have inputs. So now this is an event. We can't really double-click it as a function. So we want to reference the controller. So let's add an output. And inside of the outputs, Let's do the player controller we have here. This is the reference we want TCE player controller. And this is an object reference. Okay? And here we can call it player controller, compile and save. And you can't do anything in here. So this is all finished. Let's go back to the player controller. And now you can see it's become blue because now we have an outputs and it's not an event anymore. We can double-click it and now we can just write self. So we are referencing, it's asking what player controller is this reference? This is self because we are inside of this one. Okay? So the reference is this one. This is how you do it. And now what we can do indeed Level Blueprint. We can actually here, instead of costing, Let's copy this get pled controller. And now we can say the function we just made so set player controller ref. And remember since it's a, a interface function, it has to say message, okay? And it's also so shows through this letter icon that it's a interface function. So just like before now what we can do is bind to barrel spawner. So this is how you call event dispatchers. You bind to them. So let's delete this costing. Let's just use the plaque control logit or the interface function we just made. And let's connect everything. Okay, so when you create, when your credit event dispatchers, you call them just like an ordinary events you just learned are just like functions. You just call them just like that normally. And when you call them, when you use them in other places, you have to bind to them. And what you need to do is you have to reference to the place where you made the Event Dispatcher. In this case, we are referencing to the player controller because this is here where we've made it, okay, and you have to bind to it. And now we have an event here. So here let's create a custom events and let's call it spawn barrel. Okay, Let's compile and save. And now every time we level up, every time I press E, we are, or every time we proceed, we are going to gain coin. And every time we gain a coin, it's going to call this parallel spawner. And when you call the Event Dispatcher, it's going to fire all the events that you have bounded to. So when I press E and I gain a coin, it's actually going to fire this event. And you can do this in many, many blueprints. You can imagine that you have 10 places where you bind to this bell spawner, to this Event Dispatcher. And every time you call it, it's going to fire in all the places you have bounded to. Okay? So here what we want to do, now we have this input called coins. And this Coins is actually coming from here. So every time you press E, it's going to give us one more coin. And it's going to put it inside of this Event Dispatcher. And now we can see we have this coin that we add here. And what we want to do is just ask, is this number greater or equal to 10? So if we have 10 coins, is this true? If it is, we can go ahead and do spawn actor from class. We can spawn the barrel and the place we want to spawn it, let's promote this to a variable and call it barrel transform. And let's compile and save unless one in the middle of the map and just give it 15 so it's not beneath the ground. And we can say tried to adjust location but always spawn. And let's save. And before we could click play, remember this is a custom, custom player controller and we have to assign something here. But remember, we don't really have a game mode. And for this, let's just go ahead and create a game mode. So inside of here, you a blueprint class credit game mode, and let's call it g m game mode. Okay, now we have a game mode. Let's save everything. And inside of the ones settings, Let's change the default Game Mode to Game Mode. And you can then assign a player controller. And here we want to assign the PC player controller. And now we are using our Custom Game Mode, and it's also using the custom controller. Let's save everything. And let's see what happens. Click play. And when you press the E key, and actually let's print out to the screen so you can see it better. Else you want really visualize it. And when you add coins, I also want to, Let's, let us print a string before we do this. So print a string. And this one you can try to use rewrote notes. And you can do this by double-clicking on this frontier. And here we want to say, we just want to print out the amount of coins that you have currently. And actually, let's do it like this. That's fine. Just like that. Okay, now it's going to print them out just so we can see it. And if we click play and press the key, it says one. And it's a stew. And when you get up to the number 10, it should spawn D barrel. And you can see here, now we have spawned this bot. So what happens is, let's do, let's go through it quickly. What happens is we created this Event Dispatcher. And for event dispatchers, you call them just like when you print, when you take out a function and you want to use that function or when you call the custom events that you make. Okay, So now we call this Event Dispatcher, just like you call events. Normally. For this event dispatcher, we added a parameter. And this is becomes because we want to get affected by these coins. This is what's affecting. And these coins over here, to call this Event Dispatcher, you have to bind to it and you just write bind to and then the name of the Dispatcher that you made. And remember you had to reference to the place you made the event dispatcher. So in this case it was in the player controller. And here in the player controller we can then take out and bind to the event dispatcher. And every time you call the Event Dispatcher, every time you press E and call it, it is going to fire on all the places you have bounded to. So in this case, we have only bonded to one event though is it's bound to this event. This event is going to fire every time we press E. But it's only going to do something because we had added this condition that if we have 10 or above coins, then go ahead and spawn the barrel. And just to show you that it's firing all the time, we can just say fire down here. So if we don't have ten coins yet, it's going to say fire. And if we click play and I click E, just fire, fire, fire, fire. So it's going to fire this event all the time, every time you press E Because you have called this Event Dispatcher and it's going to fire everywhere you have bounded to. And this is very useful, especially if you bind it in many places. You can fire, you can imagine you can fire many events at once. And this is also a cool way to communicate with the Level Blueprint. This is how you use event dispatchers. Please let me know if you have any questions about it. Blueprint communication is usually a bit more difficult for beginners, but if you have a good understanding of how it works, then everything will be a lot easier to understand. So let's go over and the next section and actually develop an actual game. So far we have just used the print string and a lot of videos. And while it's cool to display all the things through a print string, it usually tends to get harder when you try to develop an actual game because it's fine. I printed a string, but how do I use it actually went out on a program again. And this is what we're going to look at. We're going to program again from scratch. And I'll show you the process of how to start from scratch. And then the lava game that's actually functional and making a wind condition and all of that. But let's go ahead in the next section and develop our first game. 59. Game Introduction: Hello and welcome to this section. So this section will focus on creating your first game. And for this one, we're just creating a very simple game as your first game to see how we use all the things that we've learned and put them together into making game. So what we're going to make is just a simple sphere that you can control whether your keyboard and you are going to lose scroll and scroll. And it will be displayed, displayed up in the top left corner you can see how many scrolls uploaded. And when I'm finished loading the scrolls, I can enter my portal. And from here it's going to display to you what kind of trophy you have. If you haven't loaded many trophies, you are going to get the bronze trophy. If you have loaded in the middle, you're getting the silver. And if you have loaded all of the trophies or all of the scrolls, you are getting the gold trophy. So this is a very simple game, but you're going to learn some things and how to, with all the things together that we've learned at from there, we can move to more advanced topics. So let's go ahead and start the game project. 60. Downloading the Project: Okay, Hello and welcome to this game project. So before we go ahead and do anything, please go ahead and download this project that I have uploaded to the site. So go ahead and download it. It's called Death collector. And what you'll see is a folder and inside of it is all of the project. Here you can see what it looks like and this is what you will be downloading. And when you extract it, you can open up the debt collector that your project. And also if you, if you don't want to open it through here, you can open it through the Epic Games launcher. When you launch Unreal Engine five, inside of there in the project, you can browse to this new project file and go ahead and open it up. Please let me know if you have any trouble opening it up. I hope not. And when you open up the project, you see all of these things. So remember when you open a project, usually you are inside of an empty level. So you have to double-click on one of the maps to enter a level. Okay, So this is something to know. And inside of this project, there is something, there are these folders over here. So we have a 3D folder, and inside of the 3D folder we have all of these assets. So these assets is what's used to create this level. And also I've just created a quick level that we can use for our game. But you can go ahead and create a better looking level if you want to. These are assets that you can just click and drag and drop here I've already, I've already added the materials and textures and all of that so you don't have to think about it. You can go ahead and drag assets and design your own level if you want to. These are all assets that is created for my game board craft. And I directed this game and recreate a lot of assets that we created. Assets for, I think about 10 months. I've created a lot of things, so this is only part of it. These are only some smaller assets of the game. And we are going to use those to create our own small game. And these artists, artists creating this, these assets are very talented, so this was really cool to work on. And apart from these 3D assets, we also have audio, and I just inserted two different as effects. And we have blueprints. I just created some lighting blueprints so you can see or if you drag it out, we have a light that we can place around. And I'll show you how to create these as well. And we are also going to create other blueprints here. We have maps, we have the underworld map, which is this current map that we're in. And we have the end map, which is this map that we're in when we finish the game. And we have this nice marketplace assets, which are for free. And we have this candle All effect, visual effects, which is just this candle lighting. Okay, so before we start, I just want to explain to you what this game is about. And what their game is about is you aren't a small ball and this ball you can control what WAS, are the arrows on your keyboard. And this ball is just rolling around collecting all the coins in the level. And then when you're finished collecting the coins, you go inside of this portal, which will then finish the game, and you will end up in this ending screen. So we will learn how to create a client's load. The coins, go over and change levels and do the ending screen. And depending on a few, if you have gotten all the coins are how many coins you have gotten, your going to get different trophies. So we have here a, a bronze trophy. We have a silver trophy, and then we have a gold trophy. So we are getting one of those trophies. And here we also have a platform which we can place the trophy on. And this will be a cool game, so very simple, just collecting coins, depending on how many coins you have collected, you'll get a trophy. And here you indie game with your character. So this will be perfect for our first game. Nothing too complex, but we will still learn a lot. And it is very cool that we before learned all the fundamentals of programming, but it is also cooler to put everything together and tried to use it. Because sometimes it's confusing when you just use print string. And sometimes it's harder to imagine how to put all of these things together that you've learned into creating a whole game. Okay, so enough talking about the game. Let's go over to the next lesson and actually start doing the project. 61. Game Mode & Player Controller: So let's go ahead and set up the game mode and player controller. So over here in the Blueprints folder, right-click and click on Blueprint Class. And let's choose the player controller. It doesn't matter what you choose first was just created the player controller and call it PC. And let's just call it the name of the game. So debt collector and right-click, create a Blueprint Class. And let's create the Game Mode. And remember the player controller is, is a Controllers and actor responsible for controlling upon used by the player. So we will use it to control the character we are creating in a bit. And the game mode is, is defining the rules of the game, the scoring, and so on. They'll create a game mode called GM debt collector. So now we have a game mode and a black controller. In order to use this game mode. And the player controller, these are the custom ones. Let's go ahead and edit and the project settings. And inside of here we have something called maps and modes. And inside of here we have the default game mode and we have to change it to the custom one we just made the GM debt collector. This is our game mode. Click on the arrow here and the selected game mode, and you will see all of these classes, the default born. We don't really have a default poignant. We will create it in a bit, but we have a player controller. So let's change this one to the PC death collector, which is our custom player controller. Let's close it down. And just to make sure, Go inside of the game mode here. And inside of the game mode. Just check here to the right that we, the player controller is actually the PC debt collector and this is correct. So this is fine. Let's close it. And inside of the world settings to the right here. So click on the world settings. You also have to change it to the muscle. Remember, click on the map you want to change it for. So let's start with the map on the world. Here in the world settings, change the game mode to GM debt collector, and just make sure that the player controller is PCI data collectors. So this is correct. Let's click on the map and look on the world settings. Change the game mode to GM debt collector and PC that collector. So remember this is a mistake that many makes. You will get confused why your game is not working the way you wanted to. And this is because maybe you forgot to actually assign the game mode. So remember to assign the game mode. And let's go ahead and open up the flood control largest ones to see if we have to do anything here. And this is looking fine. So let's What was it again? Let me click on the game mode and click here to open the full editor. And this is because the, the, the blueprint class is empty. This is why this is going to be full screen. So click on open full blueprint editor and it will open up like before. And I just wanted to see if I need to edit something here. And it also looks fine. So let's close it down and this is fine for now. We will always go back and do some changes when we need to. So let's try to set up the character upon now. 62. Creating the Character: Okay, So the character upon is just going to be a ball that's rolling around that we are going to control. So let's create this character, right-click here and create a blueprint class. Now we have to decide what the character should be. We have something called pon, We have something called character. And remember that the pon is a, is an actor that can be possessed. So we can actually control this on. We also have a character which has the ability to walk around. But you can imagine a character was two legs, two arms. The thing we have is actually just a ball. So this will be enough for us. We just need to control the ball. Don't create an actor because an actor can't receive input from a controller. So we have to choose upon, and let's call it VP ball. Okay, So this is the player, double-click on it. And inside of here we just want to make a simple sphere. But go ahead and click on add at a sphere. And here you can rename it. The way you rename is either right-click and rename or the faster way, which I usually do is just clicking F2 and you can do it with everything. You can just click off to, click off to unqualified ball. And this ball here you can see here if I compile, save and close it, if I drag it out, you can see this is the ball that is actually going to be controlled. Double-click on the ball. And let's go ahead. And here we can add a camera. We need a camera to view the ball. And we need we need like a camera like this. We need like a top-down view on the ball. So go ahead and go click on Add. And before we add this camera, we need to add a spring arm. And what a spring arm is, is you can imagine it a holder for the camera. So go ahead and, and the camera. So now we have the ball. The ball or the spring arm is attached to the ball and the cameras attached to the spring up. So now if we click on the spring on and we click on E to rotate, you can see if we rotated the camera is attached to the spring arm and we can actually just rotate it to get the correct view of the ball, but compile. So maybe we want this viewer, but we will always adjusted the when we play the game. If this is not satisfying, when we play the game, we can always go in and change the rotation a little bit. If you don't want it to snap, you can always remove this Snap appear and just rotate it to your liking. Okay, this is fine for now. And over here in the spring arm, you can also change the arm length. So how far away you're watching the ball. So this is the okay for now. We can always try to adjust it later unless make it 600 for now. And this is fine. So let's click Save All. And this is looking good. And this was it for the character set up. So now we have a character that we can place to the ground here. And you can see that we have, we have a small bug here. You can see if it goes underground. The camera sticks like this. And if we put it on the ground, it will be correct. So what we can do actually, this is because the camera here are the spring, I'm sorry. It has something called do collision test. And this is because when it hits something, it's going to do collisions with it. But we don't want to make collisions. And now when we take it down the ground, you can see it's actually not bugging, okay. And also another bug is if we drag it out, you can see the ball is actually beneath the ground. So double-click on the ball. And let's go to the viewport. Click on the ball here. And I'm just going to apply this snapping. So click, move it up once you can see it's now above the ground. We can also to be precise, this is now precise, but imagine if you had something you wanted to be more precise on it, you can use this view modes. So go to the left or right view mode. And you can see this wall needs to be above this red line, which is the ground. Compile and Save As go back to the perspective mode. And let's, let's go ahead and close this down, placing the ball. You can see now it's above the ground. And the camera is also correct. So if we right-click on this ball and click on pilot BP ball, you can see this is actually the view of the ball that we are currently in. To move out of this view here, you can actually just inject the camera here. So move out of the camera. And let's delete this vault for now. So this is very cool blueprint classes. You can always drag them in and they're ready to go. So let's go ahead in the next lesson and learn how to do the character movement. 63. Character Movement: Let us now do the character movement. So I like to do the movement inside of the player controller. So go ahead and double-click this flow controller. And I'm just going ahead and deleting all of these events. I will make my own or add them if needed. And what we need to do is use something called torque. So here we can write torque. And if you don't find it to remove this context-sensitive, we have something called a torque in degrees and radians. We are going to the one called in radians. So now torque is a force that you add to move the ball that I will show you how to move it. Torque is a force to apply to the ball so we can move it around. And this is actually not what we use to characters that have two legs, two arms to walk around. But for balls like this, we have to use a forced to move them around, which is called torque. Okay, so now I have taught, but we need an event. Remember we need to start with an event to connect with this function. And event we are going to do is when you click w, you want to move forward and so on. So instead of, instead of going in here and writing the W key and doing this, this is, this is hard-coded. You can do it like this. But the problem is, is that if you are in game and the player goes in the settings menu and the player one to change the W key to something else. You can't deploy, can't do that because w is hard-coded as the event to move forward. So a better way to do this is go to the file or the Edit Project Settings. And inside of here we have something called input. And the input, we have something called Action Mapping and access mapping. The action mapping is when you click a button and I can see that we have something called left-click. Let me actually just remove it for now. So we have an action mapping and an axis mapping. So the action mapping is when you click one button, for example, if you click eater interact with the door, or if you click G to drop your weapon. But the access mapping is their buttons we use to move and hold down. For example, the W2 move around or this to move back and so on. So in this case we are going to use an axis mapping. And here let's call it move forward. And here we are going to assign a button so we can use write W key or just W to find it. And this is the WQ. You can add them another key here because actually we're moving forward and backward, but I usually call it move forward. You can also call it move horizontal and vertical, that's up to you, whatever makes sense. So w and as to move forward and backward, instead of finding the keys here, I want to show you a better way. You can click on this button here and you click on the S key on the keyboard. And this automatically assigns it. Okay, so we have them move forward, move, and we need the move left or right, I should call it moved right. So left and right are using the D key and using the the achy. Okay? We also have scales. So these needs to be in opposite directions because the one move forward and the one move backwards, which is a negative number. And the same on this one, D is one and a is the, you can imagine it as an axis. And moving up is positive, down is negative. So just like this. And now have moved forward and move right? And these we can actually use as events. Who closed the input for now, we can come in later if we need something and open the player controller. And here you can write move forward. You can see here we have the axis event. Click on that. And we have them move forward event. So connected with this torque. And we need a target for this torque. And the target for this torque is actually this mesh over here. This is the ball, we need this ball here. We need the, we need this Static Mesh Component. So the way we do this, remember now we need to communicate with the other Blueprint. So now we need to use use either casting or a Blueprint Interface. So let's go ahead and use a Blueprint Interface. I like doing that, but let's minimize this and we need to set a reference to this bowl. Let's right-click a new folder called interfaces. Inside of here, Let's create a new interface. So blueprint and Blueprint Interface, call it int ball. And inside of this interface I want to create a new function called set all ref. So this sets the ball reference. We create an output and call it BP ball. This is what we called the, the ball blue Blueprint class. And this is an object reference to the name is the same. As the class we created here, because this is what we want to reference two. So now we have it and let's call it, let's call the, let's call it ball here. This is the value. And let's go over to ball. This is BP ball now. And inside of here, remember we have to add use. We have to add Blueprint Interfaces before they can work. So inside of BP ball, we need to go to class settings. Click on Add, and write int ball. So now we add it and you can see the interface appears. So if you click on it, double-click it. I said ball ref and hear what, what ball do you want? What is the reference? The reference itself, because we are already inside of vv ball. Oh, this is the reference we want. The now what's cool is we can go ahead and start with the debt collector. So this is the player controller. And then inside of here we can say, we can say pawn. And remember if you don't know what to search for, because when we need to call interfaces, Blueprint Interface functions, we have to call first the parent class. So what is the general function? This is the pond we need to call upon first, just like what we did with the Game Mode and player controller, we wrote get player controller and then we reference to the customer flow controller. The same thing with this point. We have to call this pond first. So if you don't know what it's called, this right pond, this is how you find them the easiest way. And here we can see something called Get Player upon. Ok, So when you, when you get to play upon, you can then reference to this point you have, this is the custom font so that we're not going to say costs to, we could have done it like cast to BP ball. But we're not creating casting. We already have an interface and the function is called set bowl reference. This is going to call this reference. And it already knows that the ball reference itself, which is this one, let's say said ball ref. Whoops, and this is the wrong one. Said ball ref. Remember that it needs to be the message because this is the interface function. And now as the ball or as this blueprint class, we can now actually grab this ball Static Mesh Component. So I'm going to write ball. And now you can see, you can click on Get ball. So now you have this ball component that you can add to this target. And this is what we want to add torque to. Let's connect it and click on compile and the error removes. And now we need to add the torques. So now we need to add the movement. And before we add the movement, before I forget it actually, let's go ahead inside of the Edit, Project Settings and maps and modes. And let's change the default Pawn Class, 2, BP bulk. So now we have this Pawn Class. Let's close it down and just double-click on the Gamow just to make sure that it's set to BP ball. That's correct. And just go to the World settings and make sure it's VP ball. That is correct as well. Okay, So this is setup and let's go back to the player controller. Now we need to decide in what direction we need to add the torque, because the torque is a force that is added to the bowl. And we can add the forest to the x-axis, to the y-axis or the z-axis. So we have to decide which one of these axis is forward and which one is left and right. Okay, Well, let's go ahead and the way you can, the way we can figure it out is just go ahead and create a cube, whatever shape you want to create and move it up. And you can see here the y-axis we can use to move forward and backward, or we can use the x-axis, so it's up to you. But we can actually use this x-axis. Now remember, the red color is the x-axis. You can see it here to the right. And we can use this x-axis and we can use the y-axis to move left and right. Let's try to do that. So let's go over to the controller. And inside of here, you can either right-click and click Split struck pin to view the individual axis. Or you can drag it out and write make vector. And you can do that as well. I'm just going to make the vector and the X axis. And this is actually when you, when you press W and move forward, this is actually going to move along the axis. So this is the axis mapping we caught early, created earlier. Well, let's move ahead and moving forward and backward, let's put it to the x. Okay, So this is because here if I inserted again, whatever shape, so applying it to the x is actually this way, so it's going to move forward this way. So moving in the positive and negative, let's go over and talk to the x. And let's compile and save. Let's click, let's click Play. And nothing happens when you try to click. And this is because you can see here it's actually flying above the ground as well. And this is a buck we have, we don't have any physics, we probably need to simulate physics. So if I click escape, it actually says that here to beer has to have Simulate Physics enabled. So let's go ahead and double-click on this ball. We can click on the ball here and down here we have something called simulate physics. Torque is physics and we have to apply it. Let's compile and click Play again and see what happens. We'll fall down. And when I click W, it's not moving. It's actually here. Let's actually place a player starts somewhere in the map so we don't start on the top. So go ahead and click on Create. And you have something called Player Start. Put this player start here, anywhere in the map. Click on Play. And now we are underground. So if I click W, nothing happens. And this is because the force we are applying, the torque we are applying is not strong enough. And what do we want to do is just multiply. Now we are going to multiply the torque multiplied by this number and see what happens. And let's put this end result inside of the vector. So now we are multiplying the force when we put W. And now we're moving and this is lunch eaten, so weird. And this is because the camera is following the ball, okay? Following the ball and we don't want to do that. So let's click head on the spring arm. And in the spring and we have to go here to the top. And this is the rotation, that's what's causing the problem. And instead of sitting the rotation type two relative, then set it to world. Okay, compile and save. And let's take a look. Also. I think our, our ball is moving in the wrong direction because this is the x axis. We have put the torque on the x-axis, and this is the x-axis. So when we press W, it's actually going to move to the side. So actually it's going, it's needs to be on the y and move forward and backward. So let me just connect it here and just put it under why? Simple fix. Let's click Play and see what happens. So now it works so it can move forward and backward. I think the movement is way too fast. So let's remove 10 from here and compile and play. I think that it's more reasonable. That's fine. Now, what is that number? 123456, zeros, 1 million here you can put, Okay, so now this is working. Now we have to move to the left and right. Remember the event we made before is move right. And we need to choose this event, not devalue building the event. Let's copy and paste this because we need the same information. So let's copy paste all of this and you can also copy this torque. Let's connect it. Okay, so now we have the same information. And I just remember to copy paste if you have the same thing, we don't need to waste time on creating all the same stuff again. So here we have the axis value, and again, you can just multiply it by the same number, move it a bit this way. And multiplying it. And this way we need to move to the side. So this is actually the x values. This is moving to the side. So to the x and compile, click Play. Let's try to flick AW India, as you can see here now you're actually moving the opposite direction because when I press D, it moves to the left and our enterprise a, it moves to the right and it needs to be the opposite of what it is right now. So to fix this, go to Edit and inside of project settings, inside of input. And here when you press DNA, these actually need to be switched. So minus one here and one here. Okay, so let's play, and now we are moving correctly. So now I can press a, W, D, and S, and I can move my ball. So this is the movement we have done so far. And if I click if 11 to see how far I am away from the screen, I can just make it make it a camera a bit further away. And then I think I'm done with this uplink the spring. Instead of 600, you can make it to 800, though the spring arm is a bit further away, so we can see a bit more. And this is the result we have so far, and I'm happy with it. Okay, This is looking great. So this was it for the player movement. Now we have a ball and it can move. And if we need to increase the speed, you can just go ahead inside of the player controller and adjusted this this multiplication number. So make it higher if you want to move faster. So the next thing we want to do is creating the coin on the ground. So let's go over to the next lesson and create that. 64. Creating the Scroll: Okay, so now we are going to make the scroll. And instead of a coin, I actually want to make a scroll. I think this is a bit more interesting. And what I've found also is this scroll here. And under the 3D and their renewables, we have this SM scroll. And this has also made for bought Kraft. I think it was a bit more interesting. Let's make scrolls instead of coins. So now we have to make these loadable scrolls. And the way we do this is go ahead and create a, an, an actor, a blueprint. So right-click on the blueprints. Create a blueprint class, and then select actor. We don't really need movement or anything. So we're going to make a simple actor, call it BP, scroll and double-click it. And inside of here, in the components we want to add a static mesh. So a simple mesh and we're going to call it scroll. Now under here and under the static measure in the Details panel, we are going to find the scroll writing, searching for scroll, looking on it. Or another thing is if you have it here in the UK or in the Content Browser down here. And also have taken here and drag it on top of this one. And this one is the BP, sorry. So we have to go and under 3D renewables and ASAM scroll and you can drag it on top of it. Okay, so now we have this scroll. And you can see here, if we drag it out to the world, now we have a scroll and this is cool. So if we click play isn't looking for, and so now we have a scroll, we can loot a problem with this or not a problem, but it looks boring. It needs a bit more movement. For example, hovering up and down. And let's do this. Let's delete the scroll for now. Go back to blueprints, double-click the BP scroll. And inside of here we want to do a code. So do some blueprints, remove these events down here. Let's do the Begin Play. And now I want to teach you about the timeline. So go over here and write timeline. And there's something called Add Timeline. So what a timeline is actually the marine him at first, and I'm just going to call it scroll movements. So what a timeline is, you can make smooth movements with a timeline. So for example, you can imagine a door in the game and the door opens smoothly. This is done with a timeline. Or if you have that day and night system and the sun goes up and then there's some sun goes down. You also do this smoothly with a timeline. In this case, we want to move the scroll up and down, up and down slowly. And this is also done with their timeline. So we can make smooth movements or a loop of bowel movements with this. So here in the begin play, instead of starting it from Play, Let's do play from start. So it's going to play the animation from start. And before we do anything, let's double-click this timeline. You get into a graph like this. And here you can add different graphs. You can add a float track. So this is the float variable, just like if you made a variable here, this is a number with decimals. You can make a vector, it can make an event track, and you can make a color truck. For this. Let's see what we need. What do we need here? So the thing we are trying to do is we are trying to adjust the location of this scroll so we are changing the location. So it starts to fear, for example. And we want to set the new location to be here and then here and then here and so on. So we're trying to adjust the location that tried to take this scroll mesh. And here we are. We are writing location. And you can see something called set relative location. Click on this one and hook it up to update. So we want to update the location of the scroll. Okay, So the new location is going to be plugged in here. So we actually, Whoops, I'm going to leave that again. So actually need a vector. So double-click this timeline and we want to add a vector track. And because this is the input we want to add, now give it a name. Let's name it. Movement or others, or location alpha, location alpha. But this is going to be the smooth movement. And this name is also going to appear over here. So this one is actually going to be plugged into here. Okay, so before we do anything, let's double-click this timeline. And here we have the x, y, and z. So right-click and click Add key to all curves. Let's add two more keys. Now. You can see here that if I drag this away, this is the x-axis, this is y-axis, and this is the z-axis because this is a vector. Remember we have three numbers in a vector. Let me control, Control Z to undo all of these movements. So let them be here. Module mark all of them, select all of them and do 0 and the time up here. And for the last one. Here you can choose that the length of the timeline, I want it to be three seconds. So the whole movement is going to be three seconds and then it will go looping again. Here I want to select the last points and do three. Here it's time three seconds, and the value is 0. So now it's here. And this one needs to be in the middle because it's going to loop up and down. And then it's going to continue looping this movement. I'm going to put 1.5, so it's in the middle. And let me try to do this. You have to test this. I think 20 you the last time I did it, 20 was the perfect number, but let's try to see you have to test it out. And in order to see all of the graph, you have to click these two button. So Zoom To Fit horizontally and vertically. So now you have this. Let's go back to the Event Graph. And we have this hooked up to update. And let's hook up the location Alpha, compile and click Play and see what happens. And you can see now it's actually moving. It moved not upwards but to all the sites. And the reason is that we actually don't want to, to affect all location. Tried to break it up and do and make vector. And we only want to affect the z, so up and down. And also with this, we can do break vector and we can actually hook it up in the z. And the other ones we want to be 000. That's fine. Just like this. And in order to straighten them, you can hold and click q. Okay, so now we have this, and let's compile click Play and see what happens. Now it's moving up and down. So this is looking correct, but it's not looping. And this is because you have to double-click the timeline. And up here in the top you have something called loop. And we can also use the last keyframe. Will compile, click Save, click on Play, and see what happens if I make it full screen. Now it's moving up and down. Can make it a bit, make it a bit smoother. If you zoom out here, you select all the points and you can right-click and do auto here. Now is doing this smooth movement to our graph. And I think we want to make this a bit larger because it's not truly moving up and down that much. So maybe 40. Let me try for you. Click on Play. And now it's looking a lot better, but it needs to be smoother when it ends. So over here we want to strive to make this a bit smoother, like this. Compiling click Play and see what happens. Okay, so now it's looking great. And now when I walk into it, right now it's too far up on the sky, so let's move it down actually, like this. Click on play. And then when I move into it you can see it's actually blocking me. We want we need to remove the collision from the scroll because we don't need it to push us away. Double-click here and the static mesh, we go down to collision and we remove the collision. So I would just do no collision. Okay, so now we can actually just move inside of the scroll without doing anything. So the next step we want to do is actually make it loadable. We did now is creating this timeline. And the timeline is played from the start. We are updating this animation, the new location for this scroll. And in the next lesson, let's actually make this scroll laudable. 65. Making the Scroll Lootable: So now it's time to make this scroll durable. So what do we want to do is when the player walks into the scroll, we are going to make it disappear. And the pleura gets some sort of points or points for looting the scroll. So let's go over and click on the scroll. And what we want to do first, one, the player walks into the scroll, something needs to happen. And for this fake, we actually need to add a trigger box or a collision box. And we need to add a trigger event. Well, let's add either a sphere or a box. And let's add a sphere collision for this one. Let me make it bigger here in the sphere radius. So just like this, I actually just want to move it away and see what it looks like in the world. And for this to happen, we need to need to click this hidden in game. We need to remove it. And we'll see what it looks like. Looks like this. And let's try it maybe a bit smaller. Let's do 100 or 120 and see what it looks like. So now we have this sphere. And what we want to do is inside of the event graph, we want to click on the sphere and at the bottom we have something called on component begin overlap. So what happens when you overlap with this sphere collision box? Okay? What we want simply to happen is just make it disappear so that the player has looted it. And this is very simple. This is just the Destroy Actor. And what actor do you want to destroy? I actually want to destroy self because we are inside of BP scroll. And so self as the target is correct. But I only want the player to collide with this scroll. So remember, and if you have several enemies in the level and the enemy walks into this box, we don't want this bug or this scroll to disappear. We only want it to disappear if the player walks into it. So in that way, what we have learned before in the other actor, this is the actor that's overlapping the scroll. We can say actor has tag. And we can now assign a tag to the player. So if we go back to this BP ball, if we double-click on it and you write tag up here. So now we have this actor tag. Let's click on the plus. And here we can write layer. And now we have given this VP ball, the tag player. And now here in the BP scroll and they begin overlap, we're going to say, does the actor has the tag player? If that is correct, so make a branch loops. So make it, if that is true, then destroy the actor. If the actor does not have the tag player, for example, the enemies, then do not do anything. Let's go ahead and click Play and let's see what happens. So if we walk into the scroll, it's supposed to be destroyed. And in doing so, so the work code works and this is working perfectly. So now what we want to do is every time you walk into the scroll, we want to add points. And let's do the points inside of the game mode. This is the one that controls the scoring. So it makes more sense to do it in here. Well, let's here and make a custom event, and let's call it add scroll. And scroll is going to add points. So here in the variables we want to make a new variable and we want to call it scroll counter. So it's going to add plus one every time we alluded scroll. So what we want to do is pull it out here. I'm not a set, just take a get out and do a plus, plus. And this way, we want to add one score every time we look at this, the scroll. But you can do is either create this custom event just like this, or you can use the Blueprint Interface. And since I want to give you an exercise in Blueprint Interfaces because it's so important to understand. Let's try to create this in a Blueprint Interface instead. So we want to create a Blueprint Interface for the game mode. So let's go ahead, go into site of the interfaces, rate a Blueprint Interface, call it int Game Mode, and double-click it. And here we need to add a function or an event, sorry, called AD scroll. So let's delete this one, compile save. Inside of the game mode, let's call it scroll. And inside of here, let us see as I scroll, this is fine. Okay, So let us here go inside of the class settings. And in the interfaces, let's add the int Game Mode, which were added. And now we can see this event. And if I just right-click and right at scroll. Oops, Not this one. We need the event. So here we have something called message, and we have this edge pole, which is the event. And you can see this is actually not being added because we have to compile and save, compile, save, file, save, and now we can add it. Now this is the, I don't want to edit this video out because actually I want to show you the mistakes so it can learn. Because now I can see at the ventricle and you can do it. So remember to compile and save this is very important. Also a good trick I can show you is here the three dots beside the compile. You can click them. And here on save and compile, you can click unsuccessful only. So every time we click Compile and it's successful, it is going to automatically save it. We don't need to click Compile and save all the time. Okay, So let's hook up this game mode. So now every time we lose a scroll, we need to say plus, plus. So this custom event that we made here, we need to call it here in the begin overlap. Because every time we walk into this, this is true. We want to, we want to add one to this counter and then we want to destroy the actor. Okay, so we need a way to call this, this Blueprint Interface from event. And the way we do this is we need to say and get Game Mode. Because this is inside of the game mode. And then we need a reference to the schema. So we need to do this too. So inside of the interface, go ahead and make another function and call it SET game mode ref. And inside of the outputs, we can choose the variable as GM, as we called it, GM, that collector. And select that one. It's the same name as this game mode. This is what you're trying to refer to. Well, let's go back to the interface and here we can call it game loads. Okay, So going back to this game mode, we can double-click this function. And here we can write self, because now we are referencing this game mode as selves, and now it knows it's this game mode. And now we can go back to BP scroll. And from this get Game Mode, we can say that k mode ref, and it's the message it is from the interface. And now we call this set Game Mode ref. And now we have this game mode. And from this game mode, the thing we want is to call this event called add Scroll, going here, writing and scroll. And this is a message because this is from the interface. And let's hook it up with the destroyed. So every time we overlap with the scroll, we are going to add one to the scroll. And then we are going to do something else, whatever we want to do. So since we haven't learned about user interfaces, and I actually want to keep this away from this course. I want to make a full user interface course. So here let's actually just use a print string. And just say, I feel is, let's use a formats for now, format text and say you have loaded, you will have looted and we need a number. So far. So now it's going scroll. So far. I was going to say you have loaded, for example, five scrolls so far. And we need to take this counter up to this format text. And we need to print string, which we can hook it up to just like this and hook up everything. And now it's going to print you have looted and the amount of scrolls so far. Okay, so let's try to put more scroll. So I'm going to hold Alt and duplicate this oval of times. So just like this, we play and see what happens. You go inside of this, you've loaded one scroll so far. We'll scroll so far. There is quote so far. Okay, so now it's working as we wanted to. And just for a small adjustments, I want to go in the viewport. Let's reduce the size of this one a bit, and we'll just go ahead and reduce this sphere to something like this. Let's compile and click Play and see if this is working fine. So now we can load the scrolls. And you can always make them more interesting by making them disappear with an animation. And you can actually use it that timeline to maybe affect the size of the scroll. So maybe they get smaller when you load them. And it can use a timeline to fade away the scroll. But let's keep it simple for now. This is looking great. Let's double-click and let's click on this sphere again. Let's go down and hit hidden in-game, so we don't see it in game. And now it's working. Now I can hop around and loot the scrolls as we want and it's going to print out how many scrolls we have loaded. So before we end the video, let's actually play some of those scrolls around. I'm going to add, let's take the player starts. I'm going to rotate it so it starts this direction. I'm going to move it back so the beer starts here. And let's add some scroll. So I want to add one here, and let's add one here. Let's just put them all around. Just like this. Okay, so now we have a couple of scrolls and the level looks complete. We can now go around and we'll scrolls. And the next thing we want to do is actually when we load the scrolls, we want to go ahead and finish here. And you can see here we can't really move on the platform. So the next lesson is about this platform. Let's try to make it work. 66. Setting up the Platform: Okay, so now it's time to work on this platform. What we want to do is when the player rolls on top of this platform, it will take the player to the winning screen. And we therefore need some sort of a trigger bug. So this platform, so we need to turn this into a, a blueprint class. So let's go ahead and go into blueprints. Right-click Blueprint Class. And let's create another actor. And let's call this one BP platform. And inside of here, let's do, let's add a static mesh. And let's call this one platform. Over in this Static Mesh, let's search for the platform. And it's not called platform, I don't remember what it's called. So in the 3D, under platforms, actually not a platform on the bottles. It's called pathway. We just call it a platform and let's search for pathway. And it's this one. Okay, So now it's inside of here, and let's go ahead and add a trigger bugs to it. And this one is going to be a trigger. Capsule is a good one as sphere could also be usable, uh, bugs. Let's try to add a capsule to this one. Oops. I think I click Control Z. Let me add the capsule again. And I want to make it larger, just like this. And we want to add it somewhere like this. Somewhere to here. And this height is fine. Okay, This is looking good. So we want this capsule and let's compile and save and over in the Event Graph, Let's delete all of this. And what we want to do just like before click on the capsule, go down to the bottom. And here on component begin overlap. We need to do some events. So let's do that in the next lesson. But before we end, I want to show you something. If you click play and you move around with this spirit that we made before, and you move on top of this platform, you are getting blocked, okay? You are getting blocked and you can't really go up this platform. This is because it has something to do with the collision of the platform. So if you click on the platform and we click on this browse button, this magnifying glass. This will take us to the platform here in the Content Browser. And you can double-click this platform. And now we are here in this viewer and this platform. And what I want to do is click on Show and then go the simple collision. This is what it's using right now. You can see this simple collision is preventing us from going up this platform that's blocking us. So the collision is not too good, but we need to do is change it into the complex collision. It's actually just like this. And you don't want to do this with all the models in the game. This will be very costly. You only want to do it when it's necessary, just like in this case, for example. And all the other components in your game that can have the simple collision, can have the simple collisions for the first case, let's use this complex collision. And right now we're only showing, so we're not applying. So here to the right, go down to collision. And in here you can see something called collision complexity. And the need to change the project default to use complex, I use simple concrete as complex. Now use complex collision as simple. Now we are using the complex collision. Click on save, compile save. Let's click on Play and see what happens. So why will screen and move over? And I need, I need a bit of speed now you can actually climb the platform. I saw we come closer, but now we can climb the platform. But we need the speed of the ball so we can fire ourselve up the stairs. And now you can see we're actually up on the platform. And now it works. Now we can actually climb the platform. So let's go ahead in the next lesson and actually code the logic for what happens when you win the game. 67. Changing Levels: Okay, so now that we have added the capsule and set up the platform, we actually want the level to change whenever the player hits this capsule trigger on the platform. Right now before we do anything, let's delete this platform. And because this is the static mesh that we had before, and let's pull over this BP platform that we made. And this is because we have this trigger, a capsule trigger on it. And let's double-click here. And over in the begin overlap for this capsule, we want to do open level. This is how we change the levels. So we open this level we want to open. And what we want to open inside of maps, this one called the map and you have to write it exactly as it's named Matt end just like this. And we only want the players to affect this trigger. So we don't want enemies to go to next level. So here we can write actor has tagged and changing the map or writing the tag player. So if the actor has the tag player, then go ahead and change them up. If it's not tagged Player, then don't do anything. So this is generally it. So let's compile and click Play. And let's go over to the platform and see what happens. And it changes the level indeed. So let's go back. And now we get a lot of errors that we can fix excess none trying to read that ball ref. Okay. So it's talking about Let's go back to the blueprints collector here. And the cool thing actually, you can click on the arrows and it takes you to the Blueprint. So it's trying to say trying to read this said ball ref, but nothing. There's nothing I can read. And this is because the player pawn is not spawned yet. When this is not spawned yet, how, how does it know that this one is? So this is something we can fix and here we can actually do a macro is valid. Okay, So this macro is valid. If it's valid, then do this. If it's not. Let's actually pull this down so we have more space. It's not, then delay it by, let's say 0.2 seconds, that's fine. Okay, So if it's not valid, delayed by 0.2 seconds when it's complete, go ahead and run. This is valid again until we tried to get it valid to go ahead and move on. Okay, Well, let's do the same here. Let's just copy this, move this over, and paste it. So now this is how you do a validated get. So is it valid? Is a player born valid? This is what we're trying to ask because if it's not valid, it can't really do this one. And it's going to give you errors, and we don't need that. Okay, so let's try to run it with this code. Let's click Play. And let's move over to the platform. Maybe I should move closer. And it moves over. And when we click Escape and we get no errors because we already fixed it. Okay, so what do we want to do inside of the new level? Let's go over to maps, go to Map end. And what we want here is let's do, let's set up a camera. So we want to set up a camera. Once you have set up their view with this camera, you can go ahead and click on top on this button on the viewport. And you can click on Create camera here and then select the camera actor. And when you do this, you can see a camera is created where you are viewing currently. So you can move around with the viewport now. And when you put G to view the icons, you can see we have created a camera forward wherever we're looking for, tried to look at some place and then click on this and the camera. But now we have grabbed the camera and this is actually the old one. I want to delete it. But now we have this camera and we want to switch to this view whenever we enter the windscreen. And the way we do this before we end the video, Let's go ahead and do this. This one is called Camera actor. So let's go ahead and end the Level Blueprint. Open the level and remember, whatever we code in the Level Blueprint is specific for that level. And here we can use the begin play. And inside of this begin play, we have something called that view targets with the blend. And let's remove this context-sensitive third view targets with the blend and can have this function. So we are going to set the camera to this one whenever we switched to the labile. So the target is the player controller. And you can see it here. Up here, target is player controller. So just drag out from the target and right get flagged controller. Let's put on the context-sensitive again and to load the player controller. And the New View target is the camera. So like on this camera, go up to the Level Blueprint again, right-click and create a reference to this camera and who get up to the new view target. Now we have this view target. Let's compile and let's go back and see if it works. And what I want to do. So I don't move this by mistake. I usually like to right-click go to transform and use the luck, act and movement. Okay, Let's save everything. Let's go back to map underworld. Let's click Play. And let's move. We're loading scrolls were going into the platform and we have changed their level to the one screen. And you can see we're actually in so the windscreen. And I can't move my mouse or moving the WASD. And this is looking really great. So now we can create whatever we want inside of here. 68. Reward Trophies: Okay, so now that we have set up the wind screen, Let's go ahead and work on the trophies. Tell the main idea is depending on how many scrolls the player has loaded, we want to either reward them with the Bronx trophy, the silver trophy, or the gold trophy. So let's go ahead and do this in a simple way. We have a platform here. Let's place it in the wind level. Remember right now we are inside of there, the map end. And let's rotate this one. Move it up a bit. Let's place the trophies on top of here. So going through the rewards and place it over here, I should probably have applied snapping what this is. Okay, we can just try to do it as best as possible. Move it in the middle. Then the gold trophy. And this is fine for now. Okay, so I want all of them to be invisible when they start. So here to the right and the Details panel, you have to scroll down and you'll see something called visible. So I want to uncheck the visible and I want to make them visible through code. So right now everything is not visible, only this platform. And I want to make one of them visible depending on how many scroll supplier has loaded. And the way we can do this is actually by using an enumeration. And before we do that, let's go over to the Level Blueprint. And let's actually reference all of these trophies that are inside of the level. So go over here in the World, Outliner and search for trophy. And these are the three trophies and our level. Let's go back to the Level Blueprint. I'm just going to make it smaller. Click on the first strophe, right-click and create a reference to it. The same with the others. Click on them with the reference. Now we have a reference to the bronze trophy, silver trophy, and the gold trophy. And what we want to do through blueprints is actually here in the Details panel. We want to affect this visibility because we want to turn it on depending on if you've got silver, gold, or Bronx. So here in the Level Blueprint, if you drag out from the from the reference, you can write visible and you can see here set divisibility. So now you're actually actually affecting this visibility. So now it creates a static mesh component for you. And we can set the new visibility to true so it's visible. And let's copy this here and paste it twice. And I'm going to hook up the silver and gold trophy. Okay, so now we have these three visibilities and what we want to do is create an enumeration. And remember we used switch on enumeration before, depending on what the value of the enumeration is, we want to play that specific code. So let's go ahead and create an enumeration inside of the Blueprints folder. Let's right-click burden new folder called enumeration. And inside of here, Let's right-click. Go to blueprints and enumeration. Call it E copays. And let's double-click it. And this, remember enumeration is just a list of items and actually a list of anything. So click on New three times. Let's call this bronze. The other one silver, and the last one gold. Okay. And when do we want to set this enumeration? Because at some point we have to set F, it's silver, gold or bronze. And we can, actually, if we go back to the map to the underworld. And this is the scroll that we made. If we double-click the scroll, you can see here that every time we overlap with the scroll, we have some events. We add the scroll. And this adds role is from the game mode. So we can open the Game Mode. And inside of here, so we could actually just put it here. So every time we hit a scroll, we are going to set the enumeration. For example, we set it to silver or whatever. But we don't really want to do that. Because, why would we set the gold, silver or bronze trophy every time we hit one of these scrolls. This is not good for optimization. We just want to do it. Whenever we hit this, this platform, then it's going to check how many scrolls you have looted. And depending on how many scrolls you have loaded, it's going to give you one of the trophies. So let's go ahead. Inside of the game mode, and let's create a new event called set trophy type. And I want to do this through the interface. So go to the interfaces, open the game mode and make a new function called set rho V type. Let's compile and save. Go back to the game mode, right, Set Role V-type, who's the event? And what this, we want to take the scroll counter and place it down here. And now, if the scroll culture is, is less or equal to 2 scrolls, if that is true, then we want to set the enumeration. So now we need a variable for the enumeration. Now we could go ahead and make a new variable here and said, set it to our E trophies and use this and set it to either bronze, silver, or gold. But the problem here is we're actually changing levels. So when your ball is hitting this platform here, we're actually changing the level. And when you change the level, the d variables inside of the game mode is going to reset because you're actually changing the level and it makes sense to reset the variables. So the only Blueprint class that is not doing so is called the Game Instance. So going back to the blueprints, you can right-click here, read a blueprint class. And inside of here, Let's click on all classes because you can't see it here. Look on all classes and search for Game Instance. And you can see here there's something, something called Game Instance. So like this one. And let's call the GI for Game Instance and call it the collector. So a game and stance is just an instance that runs all the time. It's also used a lot in multiplayer games because even though you're leaves the server, the instance is not deleted. So when we change the levels and we have variables inside of this game instance, these variables will not change, they will stay the same, whatever we said them to. So upon changing levels, we don't lose data for this game instances running all the time. So inside of this game instance, we want to create a new variable and you can call it trophies. We don't want this variable to be deleted when we change levels. And here you can find e trophies. This is the enumeration list we made. Okay, so now we have this game instance. And to make this game instance work, we have to go inside the edit editor or the Project Settings. And here inside of the maps and modes, we have something called game instance down here. And we have to change this game instance to GI debt collector. This is our Custom Game Instance. So now it should work. Well, let's go back to our game mode. And in here, when we have less or who are less scrolls collected, we want to set the lid, this operation here. We want to set the enumeration inside of the game instance to bronze, Okay? And here we can write gets game instance and we have to make a reference for the game instance. So let's make an interface. For our game instance. A Blueprint Interface, end game instance. Go inside of here. But a new function called set gain and instantaneous ref. Make an output. Buying your game instance. Ei debt collectors at it as an object reference and call it gain in tenements. Okay, let's compile and save. And let's go back to the game instance. Well, let's find it and tear. And inside of here, Let's go to the settings. Let's add our interface. So int game instance. Let's compile and save. Double-click on the earth and surface function we made. And here we can write itself. And we're now we can reference to this game instance. Let's save everything. Now back in the game mode, we got the game instance, and now we can see SET game. Said game instance rough, not, not the game, the game instance. And as the game instance, we want to use this trophies variable. So here we can say sets are all fees. So we want to set the trophies and we want to set that to brunch. Okay. So now what do you have two or less scrolls? We are going to get the bronze trophy. So we are setting the genome to brands. And if it's false, let's do here. Let's say if you have, if you have greater than two roles. And we can write something called end. And this is something for the Booleans. And we can check for something else. And you have less or equal to five that squats. So if you have either 34 or five scrolls, if this is true, so this is going to get hooked to false. So if you have more than two, It's going down to false and then it's going to check for these two. So if you have greater than two roles, but less or equal to five, we're going to set the enumeration value to silver. Get the game instance again. And we're going to set it to silver now. So instead of getting the game instance all the time, this is going to get messy. Let's actually make a variable out of this first. So inside of the begin play in the game mode, Mecca, begin play. And here we say git game instance, reference to this sensor phase. And let's right-click this and say promotes a variable and call this game instance. Now we have a variable, a reference to the game instance. So now we can actually delete this. And through this game instance, we can just say trophies. And now it can set the trophies. And now it's going to look a lot cleaner. Instead of doing this code, you can just take out the Canvas Instance and saying this. Actually, yeah, I actually just want to do it individually. So let's say set trophies. And let's hook it up to true and call this one silver. And if you have more than five scrolls, you're going to get gold. We can drag out of this again and say trophies. And let's say gold. Just like this. We could also just have hooked it up here and delete this one. I don't know if it's going to look messy. That's just fine. We can do it like this. Just like that. So now it's going to set it to either bronze, silver, or gold, depending on how many scrolls you have loaded. Okay, so now this is looking good. And the next thing we want to do is actually use this enumeration. And inside of the Level Blueprint here. In this map end. We want to do switch on enumeration to launch one of these codes. So let's go ahead and say Get game incidence. And from here sets game instance rough connectives. And here in the game instance we want to get the trophies variable. And this strophe is variable. We want to say switch on enumeration. So we want to lay that code depending on what type of trophy it has been set to. For example, if we get silver, it is going to make the silver trophy visible while it ignores the other two line of codes. Okay, So this is looking good. And I don't think we called this set trophy type event anywhere. So let's actually go ahead and call it here in the platform. So you can actually call this Trophy, trophy type 2. Two places you can either call it and we go back to the maps and underworld. You can either call it whenever you lose a scroll. Then whenever you load a scroll, you can go ahead. And here over in the scroll. Just call the set profit type. And it's going to set the type depending on how many scrolls you have. But this is not to optimize because why do you want to set the trophy type every time you lose something? We're only going to use it whenever we enter the new level. So we can actually use this platform to set it. And this is good for optimization. So you don't call a type of code all the time or it's not necessary. And we can just call it whenever we hit the platform. So in the BP platform, whenever we had this overlap before we open the level, let's go ahead and call this event called set trophy type inside of the game mode. So inside of here, we can say get Game Mode and set Gamow graph. And in here as the game mode, we can call the set trophy type. So said trophy type. And now we have called it, and now we can open the level afterwards. Let's compile and save everything. Let's hit Play and see if it's actually working or if we get some bugs. So now we're at risk goals. We enter the level and we get silver. That's nice. Let's click escape. What if we don't or what if we only look at one and hit the platform, we get we got this bronze. And let's see if we get gold. If we hit, I think it's six rolls, 1, 2, 3, or 5. And let's load this one. And let's go inside of the portal. And here we are getting the gold trophy. So the logic for the, for the trophies is working now and I just want to go through it very quickly if you can give me 30 seconds. I know the video is getting too long. Just to show you what's actually happening. So what's happening is we are walking inside of these scrolls. Every time we allude a scroll, we're getting this counter up by one. And this swale counter is counting how many moles we have loaded. Depending on how many scrolls were loaded. It is going to set our enumeration that we made. And we made it here. Great. You said the enumeration. And this variable is actually created in the game instance, which is over here. Recreated it in the game instance because the game instance doesn't delete variables or doesn't reset the variables whenever we change levels, it does. If you had added the trophy, this trophies variable inside of this game mode, it is not going to display the correct value when you change the level because it's going to reset it to the default value, which is brands. We have it in the game instance. And we actually made a variable for the scheme instance so we can use it and make the code cleaner. And we call this enumeration and set it either to bronze, silver and gold. And this event is being called whenever we hit the platform, we call this, this event over here to see what we said, the enumeration two. And once we have set it, We go over to the map. And inside of the Level Blueprint, we are going to call this from the game instance. And we do switch an enumeration depending on what the value is. We made it the trophy appear. So now we are almost finished and let's go ahead to the next lesson. And I actually want to finalize it by adjusting the camera view and also adding some sound effect and smaller things like that. So let's go over to the next lesson. 69. Finalizing the Game: Okay, so now we are almost finished. What I want to do is just some finalized things. So to begin with inside of the map, and I want to right-click on this camera, click on pilot. And here it's currently locked to a block the movement of the camera. So right-click on this camera. You can find it inside of the World. Outliner. Right-click the camera in the transform, like Honorlock actor transform to look at the movement to remove it. And now let's, let me adjust the camera to make it a bit better. Let me make the camera speed down just to make it a bit more interesting. So maybe something like maybe something like this is fine. Okay, So let me eject from the camera by pressing on this button. So now we have this camera and let me right-click it and its form. And let me love the movement again so I don't move it by mistake. So now we have adjusted the camera. And the next thing I just wanted to show you how you can add sound effects. I haven't added too much sound effects here in this file, but I just want to show you this one. And we have this LWD, okay, so before we can use them with, you have to right-click and then you have to click on create queue. So let's call it Q change level. Actually I usually call it, as you'll recall, it is S4 sound cue. And you can use that changed level. And we can right-click on the create queue and call it, let's call it loops. Okay, so now we have these sound cues and you can double-click on them. And here we're not going to go in depth of sound. But here if you want to make the volume lower, you can click on it and you can make the volume lower. So I think I'll make it to 0.5. It will at some point. That's fine. The same with alludes. I'm going to make the volume your 0.5. Instead. I show the lower 0.3. And that's fine. So now I have these sound cues and we want to add the sound every time we will do this scroll. Well, let's go over to the blueprints and click on the BP scroll. So every time we overlap with it, It's going before it destroys the actor. Let's play a sound. So let's say play sound 2D. So we have this play sound 2D. And I click on this and select the, let's select the loops. They said I was going to play a sound every time we loved one. And over in the BP platform. Let's, let's do the play sound. I don't know if it's going to sound good because we are going to change your level. Let's add it and see what happens. Change level, compile and save everything. And let's go ahead and click on Play. Or actually let's go back to the main map, the underworld and click Play. Yeah, they're changing level. The changing level sound is not playing because we changed the level directly without doing anything. But we can always try to delete it from here and we can play it and fake it from the map end. And in the Level Blueprint right away when the level begins, we can say play sound 2D. And we'll do those down a bit. And we can play the sound change level so we can fake it. By doing this. It's going to play this. Okay, so now we have the sounds in place. Of course, this is not a really immersive. We, these sounds doesn't fit too much, but I just wanted to show you how you can add sound to your A-game. And of course it's going to sound a lot better if you have real sound. If you have sounds for the ball, if you have music on top of it and so on. So before I end this video, remember to go inside of the blueprints. And for example, in the game mode, remember to comment your code is so for example, here, you can come in and say Begin Play. Then you can actually see it from far away, like from here. Instead of zooming in all the time, you can see it from far away. And I usually remember what I do in the beginning place. I, I define variables and things like that. So you can also just write it up here. And here, for example, adding roles when looted. And remember to comment all the code. I don't want to make the video too long. Remember to comment your code and a node. Another thing you can do to clean up the code is to create or to collapse your code to functions. Let me just go ahead and see if we need to collapse something, two functions. The code is fairly small. So I like realistically if I made it a big game currently and I had this code so far, I wouldn't collapse anything. I would let it be as it is. And maybe you can clean this up a bit by creating a railroad node. You can even select them and press Q to make them straight, and so on. So remember to clean up the code, remember to comment, because it's very difficult to read the code. If you come back ten days later and you don't know what you have done. Or if a new programmer begins to program on your game and he doesn't really have a chance to understand what you have done if you haven't really commented anything. But this was it for now and I hope you have had fun and learned a lot. It's pretty cool. You started from nothing. And now we have this game here. Fairly, fairly small game, but it's a good start. And you can always go over to more advanced games and topics. 70. What Now?: I've had fun teaching you about the fundamentals of blueprints. And I also hope you've had fun learning about the fundamentals and creating your own small game at the end. Now you can use what you've learned to create your own small video game, or simply create a prototype of the project you have in mind. At this point, you can continue to more advanced topics within blueprints. If you wish to create more complex video games, please keep an eye on my future courses as I want to release a course dedicated to developing games. Now that we've learned the fundamentals, if you're also interested in how to use the engine in general and design a game optimized level. You can take a look at my other course on this website called Unreal Engine five beginners course. I hope you've had fun learning the fundamentals of blueprints, and I hope to see you in my other courses.