Welcome to Blueprints and Barrels! During this chapter, you will be introduced to the visual scripting system called Blueprint. This system will be your first entry point toward creating customized functionality and content, using UE4. This chapter will show you the basics of how to create and work with Blueprints to achieve the same level of freedom that any other text based scripting language can provide. You will also expand on the engine navigational skills you learned in the previous chapter as we delve into the more complicated facets of the Editor panel and how you can communicate between the different components of the engine. You will learn all this by creating your very first UE game project, Barrel Hopper.
This chapter will cover the following points:
Now, it is time to create your first Blueprint. Instead of jumping straight into a new project, I can't think of a better place to create your first Blueprint than our Hello World
project. It is time to give our Hello Sphere
an upgrade! The first thing we need to do is create a Blueprint from our actor. To do this, we need to select the HelloSphere
actor by clicking on the Actor in the viewport or selecting the HelloSphere
name in the World Outlier. This will populate our Details Panel with the appropriate options. Just next to the Add Component button, there is a Blueprint/Add Script button, click on this now:
You will be prompted to save the Blueprint we are about to create in some folder within our Content Browser. For now, save the blueprint in the Content folder directly. Name this Bluerpint HelloUnrealBP and press the green Create Blueprint button.
You will have been presented with an entirely new window, the Blueprint window. This will be your work area whenever you are editing or creating Blueprints. The Blueprint window boasts a new layout of panels and visual sections:
When creating Blueprints, you are frequently going to want to test your recent changes and additional functions as intended. You will also want to make sure that you have minimal errors, warnings, or bugs. The way you will do this is by interfacing with the previously mentioned Toolbar. The buttons featured on the Toolbar allow you to perform varying actions that assist with having your Blueprint execute in a test environment. Each button performs the follows:
All of these options provide you the ability to debug and run your Blueprints while working on them in your project.
Each Blueprint will include and be composed of certain elements, these elements can be found under the My Blueprint panel. Each of these elements will be used by you to create the custom functionality that you require from your Blueprint.
Blueprint Graphs are the canvas with which you work to create blueprint functionality. It is within these graphs that you will place and connect your Blueprint nodes. Event Graphs house the Events that will be fired during a Blueprint's application lifetime. These events can be things like the Tick event that will be called every frame or the ActorBeginOverlap
event that will be called when the Blueprint object is overlapping another. Blueprint functions and Macros will also be constructed using the graph system; however, these graphs will be independent.
Blueprint functions are a means of wrapping frequently used functionality or functionality that you wish to expose to other objects These functions act in a very similar way to standard C++ functions. You may also specify an encapsulation level when working with Blueprint functions (public, protected, and private). Blueprint functions allow you to specify both input and return parameters.
Similar to functions but are only internally facing, meaning that they can only be called from within the Blueprint itself. Macros are predominantly used for grouping sets of simple instructions that will be called very frequently. The major difference between Blueprint functions and Blueprint macros is that macros are inlined when the Blueprint is compiled. As UE4 is a C++ based engine, all blueprints are eventually compiled down into generated C++ that can be then again compiled into executable binary. When I state that the Macros are inlined, I am speaking of traditional C++ inlining to the macro function itself it its generated C++ form.
Blueprint variables allow you to create data types that can store information. These variables are very similar to Class Member Variables in C++. You can specify an encapsulation level and default values for Blueprint variables. It is also important to note that, for every component included in a blueprint, there will be a corresponding variable that will act as a reference to the component. This allows you to access components form within your blueprint graphs.
Event dispatchers allow you to bind events to one another. For example, if you wanted some functionality to be performed in Class A when an event in Class B is fired, you can do that using Event dispatchers; or similarly you can set up these delegate relationships within single objects as well. We will cover these in detail at the end of the chapter. This is very similar to Delegates in C++ and C#.
3.141.165.180