Blueprints in Unreal is a C++ based visual scripting language built proprietary to Unreal. Blueprints will allow us to create code without the need to touch a line of text in an IDE such as Visual Studio. Instead, Blueprints allows us to create code through the use of drag and drop visual nodes, and connect them together to create nearly any kind of functionality you desire. Those of you who have come from UDK may find some similarity between Kismet and Blueprints, but unlike Kismet, Blueprints allows you to have full control over the creation and modification of functions and variables. It also compiles, which is something Kismet did not do.
Blueprints can inherit from C++ classes, or from other Blueprints. So, for instance, you might have an Enemy
class. An enemy might have a Health field, a Speed field, an Attack field, and a Mesh field. You can then create multiple enemy templates by creating Blueprints that inherit from your Enemy
class and changing each type of enemy's Health, Speed, Attack, and Mesh.
You can also expose parts of your C++ code to Blueprint graphs so that your Blueprint graphs and your core game code can communicate and work with each other. As an example, your inventory code may be implemented in C++, and it might expose functions to Blueprints so that a Blueprint graph can give items to the player.
The steps to create a new Blueprint are as follows:
Blueprint
. Inside this folder, right-click and select Blueprints | Blueprint Class. Select Actor as the parent class for the Blueprint.MyNewBlueprint
. To edit this Blueprint, double-click on its icon in the Content Browser tab.This will add a new event node to the graph.
print
into the search bar. You should see the Print String option in the list. Click on it to add a new Print String node to your graph.MyPrintString
) and change the Variable Type drop-down list to String.MyPrintString
. You should see a Get My Print String node available in the list. Click on this to add the node to your graph:MyPrintString
variable. Enter whatever text you'd like into this field. Then, to save your Blueprint, first press the Compile button in the Blueprint window and then click on the Save button next to it.Now that you've created the Blueprint, simply drag it from the Content Browser tab into the scene. Just as with our custom actor class, it will be invisible, but if you scroll Scene Outliner to the bottom, you'll see the MyNewBlueprint item in the list.
To test our new Blueprint, press the Play button. You should see that the text you entered is briefly printed to the screen (it will also show up in the Output Log, but it may be difficult to spot amidst the other output messages).
You can choose other classes for a Blueprint to inherit from. For instance, let's create a new Blueprint to inherit from the custom MyNewActor
class we created earlier:
MyNewActor
. Click on the MyNewActor entry in the list:18.188.119.81