Intro to Blueprints: Turning on a Light via the Level BP | 02 | v4.8 Tutorial Series | Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right so we are back and then the previous video we got an introduction to blueprint visual scripting we talked about what it is and how it works in this video we're going to get our hands dirty and start working inside blueprint and visual scripting and create our first blueprint script so let's go ahead and get started we are on the Unreal project browser window I'm going to create a brand new project for us for the purposes of this video series where make sure we're on the blueprint tab and we're going to use the third person template just so that we have a playable character that will run around inside of our level then we're also going to make sure that starter content is enabled so that we have some assets to play with for future videos as well and then we're going to choose a folder location to save it and let's give our project a better name than my project and call mine project blueprint so and then once you've done so go ahead and hit create project that's going to take just a second for to create our project and open it up mine's actually loading off-screen so I'll drag it into view here in a moment but what we're going to do in this video is keep things very simple as we start taking our first baby steps towards the blueprint visual scripting we're going to create a simple script that will turn on a light inside of our level whenever we start playing our game and in future videos we'll modify this script so that we set it up so that when the player enters a room it turns on the light when they exit it turns it off eventually allowing the player to press a button to turn on or off our light etc as well as some other things a little bit later in this video series but I wanted us to get started as quickly as possible with our first blueprint script here so we're going to keep things very simple in this in this video here so we have our project open we are currently on the third person example map we want to use a brand new map for this so let's go over to the file menu and let's create a new level it's going to give us the new level dialog we're going to use the default option here so I'm go ahead select the default map that's gonna open a brand new map for us now and for playing the editor here see we have a character that runs around and you can control the camera run around with a swd and control the camera so we have the makings of our level here so to get started let's build a simple room that we can place a light inside of and then we'll turn that light on through blueprint visual script so to do that let's hop down to the content browser down here we're going to go up to the starter content folder and go to the architecture folder so go ahead and double-click open it up so all kinds of static meshes in here for us to play with to construct our room so let's grab this wall door 400 by 300 just left-click and drag that into the level like so now if you are completely new to Unreal Engine 4 not just blueprints in general but completely new to Unreal Engine 4 I wanted to give you a quick primer on how to navigate the viewport here there are several videos for introduction to ue4 editor that you may want to check out but if you are completely new I figured I'd give you a quick primer on how to navigate the viewport here if you hold down the right mouse button you can control the camera inside the viewport while holding down the right mouse button if you hit W you will move forward if you hit s you will move back if you get a you will move left and you hit D you will move right Q moves you down and a moves you up so as you are holding the right mouse button you can use the WASD keys to kind of move around like a first-person shooter I just wanted to give you a little bit of a introduction to viewport controls again if you are brand new to Unreal Engine 4 so with that let's take our our piece here that we have placed into our level this widget here that we are currently looking at as a translation tool allows us to move our widget or move our actor in any direction based on the arrow that we grabbed here let's go ahead let's position them kind of next to our player start here so this is our player start let's put our door somewhere inside of our player start something like that you can see our our door piece here that's kind of off the floor a little bit quick little handy tip I'm moving my piece way up into the air like so when I hit end on my keyboard it's going to snap it down to the floor tulip for us so quick little handy tip to snap things to floor pieces below your actors that looks pretty good I think that's good enough so let's go ahead and construct the rest of this room really quickly so that we could start working in blueprint script here grab this wall 400 by 300 just going to left-click and drag that into our level and with that piece inside of our level here going to hit e on our keyboard it's going to enter us into rotation mode so just as before you can grab any of these arcs and rotate the piece we're going to grab this blue arc here and rotate it to the right so that it moves in that direction so I'm going to rotate it 90 degrees like so then I go back to translation mode by hitting W on my keyboard and now we can move this piece over and just line it up with the edge of our door frame there so it looks good so now that we have this one piece here when it's still selected another shortcut if you hold down alt on your keyboard and you grab this red arrow here and drag it to the left it's going to drag out a copy for us so that we have another copy of that piece so we're going to drag it to the other side like so it's kind of clipping into the wall a little bit something like that looks good we can do the same thing for this front piece here we select it we hold down oh and grab this green arrow just move it along to the back like so something like that now this back piece has a hole in it we don't want to do our frames so we can quickly swap this out down in the content browser if we make sure that our 400 by 300 walls still selected go to the details panel down on the far right under static mesh you could see the one that we are currently using the door frame click this little arrow next to it though it says use selected asset from the content browser go ahead and click it and BAM it swaps out that piece for us now we have four walls one of them with an opening all we need now is our roof and we'll be done with our little room here so I'm going to hold alt again and grab this blue arrow and drag a piece up into the air like so again that nifty little shortcut if I hit end on my keyboard snaps it down for me like so then I'm going to hit AE on my keyboard to go into rotation mode and grab this red here just drag it down a little bit 90 degrees like so I can see this piece doesn't quite fit line up to the edge here we can hit our on our keyboard to enter scale mode and just as before we can grab any of these widgets and scale it in any direction we're just going to take the blue one here drag it to the left to stand it out just a little bit and there we go I think that's a good enough room to get started now all we need to do is add a light inside of here so let's go and do that we can do that by going through the modes panel over here and make sure that we are on the basic tab and there you go right there is a point light we can just left click on it and drag and drop that into our level like so and we can place it inside of our room we could hit W to go back to translation mode and we can kind of position it as we see fit I think somewhere in the center like that that should be good enough okay so we have our basic little room with a light in it before we get started with blueprint visual scripting there's one thing that I wanted to point out how do we turn this light on and off we don't actually know so if we go to the details panel there's all kinds of settings for this light we could change the light color we could change its intensity etc source radius all kinds of different properties but if we scroll down a little bit and we go to the rendering section so here's the rendering section there's an option for visible it's currently checked if we uncheck this watch what happens to our light in the level turns off so this is the property that we want to affect through blueprint script this is the option that will turn our light on and off so again to keep things very simple in this video all we're going to do is turn this light on when the level begin or when the game begins so by default we want this to be off we're going to uncheck it and then through blueprint script we're going to turn it on so now that we know what we want to effect we want to effect this light we know what option controls its visibility where do we get started with blueprint script well if we go to the toolbar at the very top there's an option for blueprints click this button and it's going to give us a bunch of different options there's options for blueprint classes which we'll talk about in a future video in this series but basically we can create a new blueprint class out of out of actually currently just create a new blueprint class entirely but we can also take this light this point light that we have selected and turn it into a blueprint class with these options or we can open a blueprint class that we have previously created now all of these blueprints here came with our starter content so there's a bunch of different blueprints in here that came standard with our starter content that we haven't created but we can access them here we're not going to worry about any of these blueprint class options we're going to hop down to the level blueprint section now again level blueprint as I mentioned in the previous video is very similar to kismet in Unreal Engine 3 did want to reiterate anything that you do inside of your level blueprint is going to be specifically contained within that particular level so any script that we add here if we open up a new level all that script will go away because any script that you add to the level blueprint is self-contained within that level so I just wanted to mention that I think this is perfectly fine for us to get started so go ahead and open the level blueprint what that's going to do is open the blueprint editor interface I'm go ahead and maximize it really quickly so again I'm assuming you're completely new to blueprints this is the first time that you are looking at the blueprint editor so I wanted to give you a quick walkthrough of all the panels and all the things that they that are presented to you here inside of the blueprint editor interface probably the most notice noticeable or the most glaringly obvious panel is going to be this event graph this is we're going to be doing your visual scripting you can see there's already two nodes here by default all your connections and node 2 node connections are going to be done inside of the graph here and that's going to provide the scripted functionality for our blueprint by default there's a couple nodes here some quick navigation tips on how to navigate the graph here pull down the right mouse button that allows you to drag around inside and move around inside of our graph here you can also Mouse well down it to zoom out or mouse wheel up to zoom in and you can also hold down the left mouse button to create a selection box so you can select several nodes select individual nodes etc those are the basic controls for navigating the event graph now directly above that is the toolbar gives us a bunch of different options such as compiling which we're going to need to do once we start creating our blueprint script we're going to need to compile it before we can play in the editor we can also play in the editor and will automatically compile for us but traditionally it's a good habit to just click compile button to make sure that you compile before you play then there's an option for searching so you can find various nodes or properties or variables inside of your blueprint script there's also class settings and class defaults I don't really want to get into these too much they're their own separate beasts and I want to get into scripting as as soon as possible but properties for the blueprint can be defined with these two options and then we can play from here as well so playing the editor now directly to the left of that is the my blueprint panel this contains all of the if I go over the tab here it'll tell us right there at itself it contains all the elements that belong to this blueprint so any variables that we create in the macros or functions or anything that we create that pertains to this particular blueprint will be contained inside of the my blueprint panel over here and then on the far right we have the details panel that allows us to change like I mentioned the class settings and class defaults we can change properties of those two options inside the details panel or any variables that we create we can change its properties over in the details panel as well there's another panel that's currently missing from the level blueprint which we'll talk about more in the class blueprint there's a window that appears above the my blueprint panel called the components panel and that is what allows you to add various aspects to your blueprint so if you had that elevator blueprint and a class blueprint like I mentioned in the previous video you could have all the pieces that make up the elevator which would be components a button the actual frame the trigger box that makes it go up and down etc all those would be considered components and they would reside inside of the components window not necessarily applicable to the level blueprint but you want to mention that we'll talk about it more when we get to it in a future video so let me minimize this because I want to get a view of our level and the blueprint editor here you don't have to necessarily do this but I kind of wanted to show you something blueprint when working inside of blueprint it's going to take contextual measures to kind of help you along helped you achieve what you are after so right now we have the light selected in our level here if I go back to our level and I hit escape or not not the tilde key but I hit escape so currently there's our lightest selector you can see in the details panel let's select good fat escape and we have nothing selected inside of my blueprint here the level blueprint if I right click you can see I get the option to add a bunch of stuff for our blueprint visual script so we can add a bunch of different nodes to do all kinds of certain things but how do I get started affecting that point light that we have in our level we know that we want to turn this on and off how do I actually affect that particular light well if I select that light in the level and then right-click in the graph now we can see we have the option to access that particular point point light the level blueprint has recognized that we have the light selected and blueprint is saying hey do you want to do something with this light because you have it selected let's try and do something with it so it's giving us those options right there at the top that pertain to this particular light again if I don't have anything selected in my level and I right click those options are gone but I have it selected and I right click now I have access to those options so we can add events we can call functions for the point light etc we're not gonna worry about any of those all we want to do is get a reference to this point light we want to know through blueprint visual script what are we talking about what point light are we talking about so if we choose this create a reference to point light go and select this it's going to add a node to our graph now we know through blueprint visual script that this particular node is talking about this particular light in our level it even says it right here point light from persistent level so now that we know we have reference to our point light we know that we want to affect it and turn it what do we do next how do we proceed actually well again blueprint is going to try and help us if we right-click inside of our graph here again we can add events or functions or create reference to that point light which we've already done we can always add in any kind of nodes that we want from these options here if you recall before we opened up the level blueprint I had you go to the details panel of this particular point light and we went down to the rendering section and we unchecked visible so we know this this is the property that we want to affect how do we get to it inside of the level blueprint here if we right click again and we search for visible you can see we have the option call function on point light one set actor hidden in game so if we select this this is that necessarily what we want you see it has added the node for us it even added the reference for us we don't necessarily want to set it hidden in game we want to set its visibility how do we turn that on and off so let me select these two nodes and delete them we can do so by dragging off of our point light here so there's a pin here if we left click and drag off of it you can see it's telling us it's going to place a new node when we release the left mouse button it's going to give us the context menu and look at the very top it says actions taking a point light reference so now our menu is filtered to give us actions that only pertain to this particular point light so everything that is in this menu is presented to us in a way that allows us to affect this point light in some manner so now if we search for visible or as we start typing even as we start typing if we enter in and say V I s for example look at we get options for that rendering we have we can check is visible so we can determine if the light is actually visible or not we can also set the actor ending game we can set the visibility but if we go down to the bottom here we have the option for toggle visibility and that sounds a little bit more like what we're after there's two options here there's toggle visibility light component toggle visibility point light component in this particular instance either one of these will work as both of these are going to get the light component associated with this point light which is needed to turn the light on or off we're just going to choose the toggle visibility light component here and once you select it it's going to add some nodes to our graph here so it's added the toggle visibility node it's also added a light component node here and we now have the functionality to toggle the visibility of our point light or the light component of our point light so now that we have the ability to turn it on or off what do we do next well blueprint has again offered up some suggestions to us by default there are two nodes that are here and grayed out but these two nodes are probably two of the more common nodes used in your blueprints which is why they're here by default the event tic is called every frame so every frame when your game is running whatever is connected to this node will get executed over and over and over again every frame doesn't sound necessarily what we want so I'm going to select this and hit delete on my keyboard to delete that but the one above it is event begin play so event when play begins for this actor so this is called when the wind' play begins whatever is connected to this will get called and executed that sounds a little bit more like what we're after so I'm going to take this node and just drag it over here left click and just drag it over and I'm going to take this toggle visibility here and just drag it up just a little bit like so and what we're going to do now is take the output pin the executable here just left-click and drag and plug that into our toggle visit toggle visibility now notice as I drag this over into the executable in here I get a green checkmark however if I try to plug this into the target pin or even this boolean pin here you can see it says executable is not compatible with scene component reference or with boolean it's only executable with other executables so I can only make the connection from one executable to another executable so once we've done so this node becomes highlighted and we are now using the event begin play and we have connected it to our toggle visit our visibility so I didn't want to mention one more thing before we test this out here notice the two coded wires here this also again is blueprint trying to tell us what is happening just from a visual standpoint and help provide some clarity on what connections are being made so currently we are using an object connection here with this blue wire so we're connecting object reference to our target here and our executable wires are white and there's other executable or excuse me not executable there's other wires that are color-coded such as vectors transform etc we'll get into those a little bit later boolean's example if I drag off of this pin here you can see I get a reddish or pink color just kind of blueprint trying to help you visualize what's going on with your connections so with our script currently set we are saying when event begin play is called whenever we start our game this node will get executed first thing that's going to do is hop over to our toggle visibility and it's going to call this it's then going to get the target that it's supposed to be affecting which is our light component and the light component is targeting our point light so in essence our light should get turned on when we apply so let's compile and then let's actually hop over to the drop down here next to play because I'm going to simulate this instead of actually playing so I'm going to click this drop down here and I'm going to go to simulate so when I click this in the background our level will be simulated our light will come on but I want to simulate because I want to show you something else here really quickly before we wrap up this video so if I had simulate boom our light is on in our level and also you may have noticed it the event begin play was fired and you can visually see it being executed if I stop and I hit play again watch this these two nodes here you can see that it gets fired it's feeding into our toggle visibility and our light comes on so let's stop let's actually click our drop down and you know what actually let's close this blueprint I'm going to click the X mark here to close it click this drop down let's play in the selected viewport here so you can see our light is on our player character is affected by our light I think this is a good point to stop we are 22 minutes in we created our first blueprint script here that's going to do it for this video we have inside of our level blueprint if I go back to our level blueprint here created our first script to toggle the visibility of our point light that we placed in our level in the next video we'll turn this into a toggle so that the light can turn on or off instead of just on that's going to do it for this video thank you guys for watching and we'll see you in the next video
Info
Channel: Unreal Engine
Views: 267,042
Rating: undefined out of 5
Keywords: Unreal Engine, Epic Games, UE4, UDK, Unreal
Id: _zoyaVdqHQ8
Channel Id: undefined
Length: 22min 45sec (1365 seconds)
Published: Fri Jul 31 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.