Blueprint Quickshot: Making Procedural Content | 06 | v4.7 Tutorial Series | Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
♪♪♪ Wes Bunn: Hey once again everyone. In this video, we are going to take a look at how we can use the Construction Script to create customizable Blueprints that a level designer can modify inside the Details panel without having to go inside your Blueprint and make those modifications there. We will also show you how to use the Construction Script to create procedurally generated content really quickly. Let's go ahead and get started. Go to the Props folder within the Starter Content folder that I included with this project. We are just going to use this SM_MatPreviewMesh_02 because we want the level designers to be able to make it a custom version of this particular Mesh. Right-click on SM_MatPreviewMesh_02. Under Asset Actions, select Create Blueprint Using This... UE4 asks for a name. I am going to leave the default name. That is fine. We are inside the Blueprint Editor on the Viewport tab looking at the Static Mesh we just turned into a Blueprint. Go to the Construction Script. This script is a little bit different than the Event Graph. If you recall, the Event Graph executes any kind of functionality that we want to occur at run-time while our game is playing. The Construction Script fires any time properties of this Blueprint are changed inside the editor. The Construction Script is very handy, especially for customization purposes. Let's go ahead and see how we can do this. Inside the Components panel, select StaticMesh. All of these properties that you see for StaticMesh, such as the Materials for example, or whether you are simulating physics, these can all be defined inside the Construction Script as variables that can then be exposed to your level designers. Let's see how we can do that. Let's say we want to change the Materials of StaticMesh. Hold Ctrl + drag StaticMesh into the graph. Drag off StaticMesh, type and select "Set Material". Now we can specify an Index and a default Material to use. Press Ctrl + C and Ctrl + V to copy and paste the Set Material node . Plug the Construction Script into Set Material. Plug the Set Material output into the Set Material input. Set Element Index to 1 because we have Element Index 0 and Element Index 1 for this particular Static Mesh. Plug Static Mesh into Target. The next thing we need to do is promote our Materials to variables. Now we could specify what the Materials are, but we want to make these variables. Drag off Material here and select Promote to Variable. I am just going to move that variable down so it is not hiding up there. Drag off the other Materials, and select Promote to Variable. Move the variable down. Inside the Details panel, we can name the variables. Set Variable Name to "Index 0". Click the Editable checkbox. When you click the Editable checkbox in the Details panel, you will see the variable in the My Blueprint panel has an eye icon. This eye icon shows you that it is a publicly editable variable. Repeat the process for the other new variable. Set Variable Name to "Index 1". Click the Editable checkbox. Now, click Compile and click Save. Once we Compile, you see we have the option of setting the Default Values for these variables. Let's go ahead and set some of the Default Values for our level designers. Select Index 0. For example, click the Asset drop down and select M_AssetPlatform to make it white on the outside. Click the Asset drop down and select M_Metal_Gold to make the outside gold. Click Compile. Go to the Viewport, you can kind of see the colors. There is our default Static Mesh. Go back to the level and find SM_MatPreviewMesh_02. I saved mine in the Blueprints folder. Drag SM_MatPreviewMesh_02 into the level. There is our default setting right there. Now our level designers can look in the Details panel and change the settings if they would like. For example, you can hold Alt + drag out a copy, click the Index 0 Asset drop down and select Mesh is M_Brick_Clay_New. Click the Index 1 Asset drop down and select M_Metal_Steel. There you go. There you go. You can now have a customizable Blueprint that your level designers can modify on the fly in the Details panel without having to go into the Blueprint itself and make those changes. This could be done for anything. Go back to the SM_MatPreviewMesh_02. For example, let's say you had a light. Click +Add Component, type and select "Spot Light". Let's add this for fun because it looks like one of those spotlights that you see at movie premiers. Let's go ahead and move it up. Press E to use the Move tool to rotate the light and back down. That looks like a spotlight. You could also add this light to your Construction Script as well. Hold Ctrl + drag SpotLight into the graph. Drag off Spot Light, type and select "Set Intensity". Plug Set Material into Set Intensity. Drag off Spot Light, type and select "Set Light Color". Let's see; I think those are good. You get the idea. Drag off New Intensity and select Promote to Variable. So this is the intensity or brightness of the light. Click the eye icon to make this variable editable. Press F2 on NewVar and type "Brightness". That's about right. Drag off New Light Color and select Promote to Variable. Press F2 on NewVar and type "Color". Click the eye icon to make the variable Editable. Click Compile and click Save. This will give us some defaults to play with. In the Details panel under Default Value, set Brightness to 10000. In the Details panel under Default Value, click the Color Picker and select a green for example. Let's move the node down. Let's move that down. Click Compile. Go back to the level. We now have our Static Mesh that also has a Light Component. Hold Alt + drag out a copy. Point the light towards the wall so you can see it. You get the idea. Now, it has a green light. Hold Alt + drag out a copy. Inside the Details panel, click the Material drop down for Index 0, and select M_Cobblestone_Smooth. Inside the Details panel, click the Material drop down for Index 1, and select M_Tech_Hex_1. This Light Color is red. There you go. That is a customizable Blueprint. Really quickly, we also want to show you how to create some procedural content. There are several different ways that you could do this. We are going to show you a quick example using the Construction Script. Right-click in the Content Browser, and select Blueprint Class. In the Pick Parent Class menu, select Actor. For example, we want to create some random bushes in our level. Name this Blueprint Class "Bush_BP". Double-click Bush_BP to open it. You see we have no Components in here right now. It is just an empty Blueprint. Go to the Construction Script. We need to define how many bushes we want randomly spawned. That value is going to be a variable. Click +Variable, and type "How Many Bushes". We don't want the variable to be a Boolean. Click the Variable Type drop down and select Integer. Click the Editable checkbox. We want this to be publicly editable. Under Default Value, set How Many Bushes to 5. Right-click in the Construction Script, type and select "ForLoop". Connect the Construction Script to the ForLoop. Set the First to 1. Drag How Many Bushes on top of Last Index, which is the max. Last Index is going to be something that our level designers can define. We will at least place 1 bush, and the max that we place is whatever our level designers decide. Drag off Loop Body, type and select "Add Static Mesh Component". In the Details panel with this node selected, we can specify the Mesh that we want to spawn. So if you recall, we have nothing in here yet. But once we define a Static Mesh to spawn such as SM_Bush, and click Compile in the Viewport, our bush has spawned via the Construction Script. The node is asking for a transform. Right-click in the graph, type and select "Random Unit Vector". This is going to place our bush in a random X, Y, Z coordinate. We do want to make one modification to it. Drag off the Return Value, type "*" and select Vector * Float. This will give us a range. For fun, we are also going to promote this to a variable that our level designers can specify. Drag off B of the multiply node, and select Promote to Variable. Set Variable Name to "Modifier". Click Compile. In the Details panel under Default Value, set to 100. For our purposes, we don't want the Z coordinate. In this particular example, we only want the X and Y coordinates. Drag off of the Multiply node return value, type and select Break Vector. Breaking the vector gives me the X, Y, and Z coordinates. Right-click, type and select "Make Vector". Connect X to X and connect Y to Y. Leave the Z alone because we don't want height. We want to keep it all on the level plane. Once I connect the Return Value to Relative Transform, a Conversion node will be created for me. I will quickly double check that I specified Modifier. Click Compile. Go to the Viewport. You can see that we have multiple bushes spawned in our viewport. If we drag them in our level... Drag Bush_BP into the level. As we move the Bush_BP around the level, it is being updated with a random amount of bushes we specify. Go back to Bush_BP really quickly. We didn't make this publicly editable. In the My Blueprint panel, click the Modifier eye icon. Let's make sure that both variables are publicly editable for our designer friends. Now inside the Details panel, we have both of those options. In the Details panel, set Modifier to 1000. For example, set How Many Bushes to 60. Now you can see how we could use this to our advantage when we are placing things in our level to give us a random appearance. These are all procedurally generated via our Construction Script. There you have it. You have learned how to create some procedural content in its minimalist form, as well as how to expose variables allowing you to have custom Blueprints as well. We hope you enjoyed this video, and we will see you next time. ♪♪♪
Info
Channel: Unreal Engine
Views: 44,073
Rating: undefined out of 5
Keywords: Unreal Engine, Epic Games, UE4, Unreal, Blueprint
Id: x98lmpJv1sA
Channel Id: undefined
Length: 11min 30sec (690 seconds)
Published: Mon Apr 20 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.