Join Craig Barr for an in-depth discussion in this video Blueprint animation: Lighthouse light, part of Unreal Essential Training.
- Blueprints in Unreal Engine 4 is a powerful Visual Scripting environment that allows developers and artists to create very complex functions in a very less complicated manner. So this is a way for the non-programmers out there to create things as powerful as the ability to program or to take advantage of that idea of scripting things for our scene. So you can see here that our scene is really coming along quite nicely now, we have some nice effects, we have a really nice environment happening. Of course we have our hero assets in here.
And we've created in a previous lesson, this nice lighthouse light setup. Well now we want to take advantage of creating a simple Blueprint, a Visual Scripting series of nodes that will drive the animation on that. Now we could do the animation on this in several different ways within Unreal Engine 4. We could simply key or animate the rotational value of the center of that light, but we may want to have more procedural control over this. And this is the beauty of using something like Visual Scripting. You're not limited to one aspect, you have unlimited access to several functions of variables that tied together create infinite possibilities.
So, as a loose example here, we could create something that we can over time add things like the intensity, overall brightness of our lights for our lighthouse. The reach, or the scale of how far the beams might reach. The speed of the animation for example, and perhaps even the color of the lighting effect that we may want to work with. In this case here, we'll keep it simple, we'll look at how Blueprint Visual Scripting works within Unreal Engine 4, and how we can take advantage of that to create a simple animation for us here.
And just as a note, down in the Content Browser here, if you want to play with a completed version of this Blueprint, I've actually created a simple little lighthouse_blueprint for you that you can drag into this scene and it does exactly what we're about to construct here. So, with that in mind, let's go in and create some nice Visual Scripting. So we want to control our lighthouse light within our environment. If you go over to the World Outliner and you scroll down, you'll see that we actually have, from a previous file, how we built our lighthouse light.
And if I click on that, you'll see in the Details Panel we have several Components listed. Just a quick overview as to how that's assembled. That was using underneath the Basic Selection here in the Modes, an Empty Actor. An Empty Actor was simply dragged into the scene, placed at the center of that top of the lighthouse, or the lighthouse capital. And several Components were added inside that Actor to be able to assemble this overall lighthouse beam effect. And if we recall, over here we have each side of the light beam is constructed with a simple Point Light to provide reflection inside, a Spotlight to project light outward, and a simple little Static Mesh tube-like structure with a fade off material that provides that overall lighthouse beam effect.
And we can certainly see that if we tumble around in the environment, it looks pretty good. So let's add some Procedural Animation to this. Let's grab our lighthouse light, and we have a couple of ways that we can get into the Blueprint Level Editor here. Now as I mentioned before, previously here, the Blueprint icon up above will let you do that. This is where you can create an entirely new empty Blueprint Class and we could do that for this, this specific function that we want to do here. But we're going to actually work at the Level Blueprint Operation, and that is something that is at the global environment of the entire level.
So Level Blueprints, any functions created there are applicable right across the entire scope of the level, whereas Classes are individual specific classes to do specific functions, so we certainly could create a new empty Blueprint Class for what we're about to do here, but let's work with our Level Blueprint. Now just to show a couple of different ways that we can get into the Blueprint Editor, because we have this Empty Actor Component hooked up here, it's going to let us click and edit the Blueprint associated with it, or we could jump into the Details Panel right beside the Components here, and actually click the drop-down menu and open up the Blueprint Editor.
Let's do that. So just simply left click on that. And it's going to bring open a Blueprint Editor, and I should point out if it comes open like this in a floating window, you can work this way if you'd like. I prefer to grab that tab, drag it up top and take advantage of the large amount of real estate that we have in the User Interface to be able to work and build the node-based scripting here. So a quick overview of what's happening in the Interface for Blueprints. You have the Toolbar along the top. We'll get into some of those features there, the most important ones to keep in mind is this Player Simulate area where we'll be able to view what's happening as we construct our nodes.
And probably most important on that Toolbar is Compile. So anything that you create has to be compiled. And the reason why it's built this way, it's the exact same as classic traditional scripting where you're working in a console and you're writing out lines of code, at the end of that you have to compile it in order to be able to see your results or the overall effect of it. And that's the same thing here. In order to see the results out in our scene, we need to compile our code at the end of any scripting session here within the Event Graph.
So as I just mentioned, this is referred to as the Event Graph, and this is very familiar to you if you've been working within the Material Editor or other editors, for example, even Cascade has a similar type of setup here in Unreal Engine 4, and the navigation is very much the same. You hold down right mouse button to move around, and left mouse button to select objects and drag and drop objects, and also your middle mouse button to kind of zoom in and out of the editor here. Now on the top here we have this Event Graph Tab and this is where we'll be doing most of our work.
We also have this Construction Script. We won't be working specifically with this, this is for providing different detailed scripts that you can actually assemble yourself and drop into the scene. For this example we're not going to be using that so you can ignore that or you can drag it to the end of the graph here, because we will be working with these two tabs, or you can simply shut it right down if you want. Now the Viewport Tab is important because this actually gives us a preview of what we're doing with our Visual Scripting in relation to the components that we're specifically working with. In this case here, because we're working with this lighthouse light, we will see that only in this Viewport.
So it's a nice way to work, we can switch between our Event Graph and our Viewport as we construct and assemble our Visual Scripting notes. So let's go back to the Event Graph and take a look here again at our lighthouse. So as I mentioned before, the description here, we have this simple Base, which is just a simple little Arrow Component, and it's essentially that's just operating as a parent. It could be anything really. Ideally you want something that's not going to necessarily render in the scene if you don't need to see it, or at least something you have control over that ability to shut that render version off if you need to.
Now we want to work specifically with that base as our parent to rotate our controls. Now we have a couple of ways that we can work with this within the editor here. If I left click on Base and drag it right into the Event Editor, you'll see that I've actually just dragged a node in, and this is just a simple little node that is directly linked to what I've just dragged out of the Components there. And this is really nice to be able to grab any Component here, left click and drag it into the scene, it's now live, literally live in that scene for you to start doing some scripting with.
So we don't need the Point Light for this. I'm just going to get rid of that node. We are going to work with the Base Node, but we're going to take a look a couple other interesting ways that we can work with that within the realm of Visual Scripting here in Blueprint. So if I have my Base selected in here, there are a couple interesting things that I could do. I could come into my Editor here and at any time I could right click, and this is where it brings up our Menu of Functions or Variables available. And this is where we can start to select any of those and be able to bring them into our scene. Now we want to add a function here to drive the rotation of our overall lighthouse light.
So I want you to start typing in add. Start typing in that and you're going to get a bunch of different Actors in here and we could start to look through a bunch of different ones in here. We can also, if we're not sure what the actual name of the Component would be, we can come back up into here and we could start to dial down and start to look for some of the different basic settings that exist for creating different Visual Scripts. Again though, if we're not sure which one it might be under, this is where we can start to search for things. In this case, I want to work with Rotation, and much like you would work with in Cascade or any of the particles in there, you'd find a Local Rotation.
So I'm going to use literally this Add Local Rotation Function. You'll see that because I have Base selected up in the Component section there, it's putting in brackets, Base, so it's actually going to just add that for me if I click that. So let's click that. And that's kind of nice, it's actually hooked it up already for me. So there are two ways that we could've brought that Base in, one by dragging and dropping it in, or just by simply selecting and finding a function here so that it actually wires it up for you. Let's leave the one that's wired up. Select this one and hit Delete to get rid of it, because we don't actually need to work with two of them, we just want our simple one here.
Now what's happening here is that we have the Base coming into a Local Rotation. We're telling the Local Rotation that we want to drive the Base here, we want to turn this Base. Now we know that Unreal Engine 4 is a Z or Zed-Up World so we do want to work in Zed. This is where we want to work as our primary access to rotate that around. Now we do need something here to drive the function that will read in at every single frame of playback within the scene. And what that is within the Scripting world, or even within the Unreal Engine 4 world, is something that's called a Tick or an Event Tick.
And we can find that by let's just right click and start to type in Event. And you should find this little one here, Event Tick down below. Just click that. An Event Tick is going to be called out every single frame when we hit Play, and this is important, that's essentially what we want. We want something that is going to connect to the Local Rotation, that is telling it to drive this every single frame when the scene is being played, to rotate this base value here, which actually operates as our parent for all these other lighting components and these little Static Meshes.
So let's wire this Event Tick in. We've now just told it we have this operation to be called every single frame of playback. And if we go into the Viewport, we'll see nothing's happening, and that's simply because we haven't driven anything or connected any Rotational Value to our animation here. So let's go back to Event Graph and we know, as I mentioned, that we want to work with the Z or Zed-Up, so let's start to work with that. We can either start to dial in a small amount, let's put in something like point two, and just see what that gives us. Now if we go back to the Viewport here, we can see that nothing is happening there, but this is where if we click on the Play up above, and we'll dial that down, make sure Simulate is selected.
So if we hit Simulation, that's just going to start to show our live view here. Play is actually driving what's going on in the scene. We haven't compiled this yet, so it's not going to be in our scene working fully yet anyways, but we can certainly Simulate to see what's happening. That looks good, but I think it's going to be a little too slow for what we want. Let's put something that's a little bigger. Maybe something upwards of about a one point five on that. Go back to our Viewport and hit Simulation, and we can see that we're starting to get maybe something a little bit better, but I want to bring in maybe a little bit faster on that.
That should be fine there. If we go back to our Viewport, and that's kind of giving us overall a nice bit of animation on that rotation there. So if we go back to our Event Graph, there are many other things that we could start to hook up, things that control the overall color of the light, the brightness or intensity of the light as I mentioned, and even the reach or the overall scale of those beams. Let's leave it for now as to what these specific little Visual Scripts are doing, and let's add this to our scene. This is why we need to compile it. So we're going to need to go up to our Compile window.
You can see the question mark. That's telling you that it is not compiled and it needs to be, just simply click it. Once you see a green check mark, it's ready to go. This has been compiled and we should actually see that update here, within the Viewport as well. So that's updating with all of our different settings that we have within the scene. So we know that it's compiled and we're good to go. If we come out to the full scene here, let's click in the scene and hit Escape, so that nothing is selected within the environment. Then go underneath your Play icon here, and make sure Simulate is selected, and then what we can do is just simply hit Play in here and there is our lighthouse coming to life within our scene.
So we're starting to see this overall lighting effect, and we're even seeing the lighting go along the trees which is kind of nice there too. So this is going to look really good once it starts kind of driving through the fog here as well. Let me just click on something here to zoom in, and I'm just going to tumble around and kind of frame in the overall scene so that we can see what's happening there, and I'll hit Escape to deselect everything. And there we can see our simple lighthouse light being driven by that simple Blueprint Visual Scripting Nodes that we've wired up here within Blueprints.
So that's a really simple setup as to how Blueprints work, what Blueprints are about, and how powerful they can be. It really is limitless what you can do with Blueprints, and I'd actually encourage you to look at Blueprints as your sole driver for anything that you want to control within your Unreal Engine environment, simply because you have just that, full control. You can come back and easily edit and add more to it, it really is infinite what you can do with Blueprints in Unreal Engine 4.
- Customizing the Unreal UI
- Creating a new project
- Creating landscapes
- Blocking out levels
- Assembling a scene
- Working with materials and lights
- Adding post-processing effects
- Defining bodies of water
- Adding atmospherics, foliage, and wind
- Working with the Blueprint editor
- Creating cinematics
- Monitoring performance
- Packaging a game for distribution