Blueprint Actors
In UE4, the word Blueprint can be used to refer to two different things: UE4's visual scripting language or a specific type of asset, also referred to as a Blueprint class or Blueprint asset.
As we've mentioned before, an Actor is an object that can be placed in a level. This object can either be an instance of a C++ class or an instance of a Blueprint class, both of which must inherit from the Actor class (either directly or indirectly). So, what is the difference between a C++ class and a Blueprint class, you may ask? There are a few:
- If you add programming logic to your C++ class, you'll have access to more advanced engine functionality than you would if you were to create a Blueprint class.
- In a Blueprint class, you can easily view and edit visual components of that class, such as a 3D mesh or a Trigger Box Collision, as well as modifying properties defined in the C++ class that is exposed to the editor, which makes managing those properties much easier.
- In a Blueprint class, you can easily reference other assets in your project, whereas in C++, you can also do so but less simply and less flexibly.
- Programming logic that runs on Blueprint visual scripting is slower in terms of performance than that of a C++ class.
- It's simple to have more than one person work on a C++ class simultaneously without conflicts in a source version platform, whereas with a Blueprint class, which is interpreted as a binary file instead of a text file, this will cause conflicts in your source version platform if two different people edit the same Blueprint class.
Note
In case you don't know what a source version platform is, this is how several developers can work on the same project and have it updated with the work done by other developers. In these platforms, different people can usually edit the same file simultaneously, as long as they edit different parts of that file, and still receive updates that other programmers did without them affecting your work on that same file. One of the most popular source version platforms is GitHub.
Keep in mind that Blueprint classes can inherit either from a C++ class or from another Blueprint class.
Lastly, before we move on to creating our first Blueprint Class, another important thing you should know is that you can write programming logic in a C++ class and then create a Blueprint class that inherits from that class, but can also access its properties and methods if you specify that in the C++ class. You can have a Blueprint class edit properties defined in the C++ class as well as calling and overriding functions, using the Blueprint scripting language. We will be doing some of these things in this book.
Now that you know a bit more about Blueprint classes, let's create our own in this next exercise.
Exercise 1.03: Creating Blueprint Actors
In this short exercise, we will learn how to create a new Blueprint Actor.
The following steps will help you complete this exercise:
- Go to the
ThirdPersonCPP -> Blueprints
directory insideContent Browser
and right-click inside it. The following window should pop up:Figure 1.18: The options window that appears when you right-click inside content browser
This options menu contains the types of assets that you can create in UE4 (Blueprints are simply a type of asset, along with other types of assets, such as
Level
,Material
, andSound
). - Click the
Blueprint Class
icon to create a new Blueprint class. When you do, you will be given the option to choose the C++ or Blueprint class that you want to inherit from:Figure 1.19: The Pick Parent Class window that pops up when you create a new Blueprint class
- Select the first class from this window, the
Actor
class. After this, you will automatically select the text of the new Blueprint class to easily name it what you want. Name this Blueprint classTestActor
and press theEnter
key to accept this name.
After following these steps, you will have created your Blueprint class and so have completed this exercise. After you've created this asset, double-click on it with the left mouse button to open the Blueprint editor.