Choose your operating system:
Windows
macOS
Linux
With the release of Unreal Engine, version 4.15, the Set container type has been added to the Blueprint Application Programming Interface (API) in Unreal Engine 4 (UE4). If you're unfamiliar with the term "container", think of a storage box, where you label items and place them inside of the box for immediate (or later) use. If you've used Arrays to store and work with collections of items, you've already started using Blueprint containers in UE4. For example, when using Arrays to store items for later use, the item's label is its place in the array; however, when using Sets, the label is the item itself. This makes Sets a powerful addition to the Blueprint API.
Blueprint Sets are an exciting addition to the Blueprint API because they support efficient lookups and retrieval with keys, where a key is an item itself. The Set's characteristic, where an item's key is the item itself, means that Sets enable developers to efficiently add, find, and remove items located in the container. Depending on your game, Sets can be used to ignore commonly used words in dialogue, or they can be used to store unique inventory items. Clearly, there are many potential use cases when working with Sets; however, before you can harness the power of Sets in your game, you'll need to learn how to properly use them in UE4.
As you read through this page, you'll learn how to create and edit Blueprint Sets. You'll also learn about the properties of Blueprint Sets, which are being included to help you get the most out of using Sets in your game projects.
For illustrative purposes, we're using a Blank Blueprint Project (with highlighted settings) to show you how to create and edit Blueprint Sets.
Creating Sets
To create a new Blueprint Set, follow these steps.
If you don't have a Blueprint Class to work from, go ahead and Add a new Blueprint Class to your project.
Click for full image.
Now, select Actor from the list of classes being shown in the Pick Parent Class menu.
After naming your Actor class, go ahead and open the newly created Actor class by double-clicking on the Actor, which is located inside of the Content Browser.
[
To begin editing the Actor's Blueprint script, select the Event Graph tab.
Click for full image.
With the Actor's Event Graph open, hover your mouse cursor over the Variables submenu to reveal the + Variable button.
Click for full image.
Now, create a new String variable, naming it
MyStringSet
.[
Currently,
MyStringSet
is a single String variable. To begin turningMyStringSet
into a Set container, click on the Variable Type button, which is on the right side of the Variable Type label inside of the Actor's Details panel.Click for full image.
At this point, a drop down menu will appear, showing you four container options. Select the { } option to convert
MyStringSet
into a Blueprint Set.
Excellent work, you've just created a new String Set container (named MyStringSet
).
Editing Sets
Before you can edit a newly created Set, you'll need to compile the Blueprint encapsulating the Set variable container.
[
To edit
MyStringSet
, click the Blueprint's Compile button.Click for full image.
After compiling the Blueprint, you'll notice that the Set's Default Value (located in the Details panel) shows that
MyStringSet
is empty.Click for full image.
To add a new String element to
MyStringSet
, click the Add (+) button, located next to 0 Set elements in the Default Value menu of the Details panel.Go ahead and click the Add (+) button once again.
Unreal Editor will emit a warning if you try to add an element to a Blueprint Set before updating a new element's default value.
Add three elements to
MyStringSet
, naming themApple
,Banana
, andCherry
.Now, add one more element, naming it
Banana
.Unreal Editor will emit a warning if you try to add a new element with the same value as an existing element.
With the aforementioned warning in mind, go ahead and name the fourth element
Date
.
Well done! You've just created a new Blueprint Set, having added and edited four elements.
Container Properties
If you want to get started with using Blueprint Set containers in UE4, please refer to the following property list.
Items (or elements) in a Set must be unique.
All items in a Set must be defined (initialized).
Under-the-hood, items stored in a Set are unordered.
All items in a Set are homogeneous (of the same type).
Adding, removing, and finding items in a Set are fast operations.
The value of an item in a Set is also the key being used to find it.
Currently, Blueprint Sets are immutable, which means that they cannot be modified after they are created.
Now that you know how to create and edit Set containers in Blueprints, check out the Blueprint Set Nodes reference guide to learn more about the Blueprint Set Node Interface.