Blueprint Sets

Creating and editing Set containers, an advanced container type, in Blueprints, including an overview of this container's properties.

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.

sampleProject.png

sampleProject2.png

Click image for full size.

Click image for full size.

Creating Sets

To create a new Blueprint Set, follow these steps.

  1. 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.

  2. Now, select Actor from the list of classes being shown in the Pick Parent Class menu.

    creatingSets_Step2.png

  3. 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 .

    [ creatingSets_Step3.png

  4. To begin editing the Actor's Blueprint script, select the Event Graph tab.

    Click for full image.

  5. With the Actor's Event Graph open, hover your mouse cursor over the Variables submenu to reveal the + Variable button.

    Click for full image.

  6. Now, create a new String variable, naming it MyStringSet .

    [ creatingSets_Step6.png

  7. Currently, MyStringSet is a single String variable. To begin turning MyStringSet 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.

  8. At this point, a drop down menu will appear, showing you four container options. Select the { } option to convert MyStringSet into a Blueprint Set.

    creatingSets_Step8.png

Excellent work, you've just created a new String Set container (named MyStringSet ).

creatingSets_Step9.png

Editing Sets

Before you can edit a newly created Set, you'll need to compile the Blueprint encapsulating the Set variable container.

[ creatingSets_Step10.png

  1. To edit MyStringSet , click the Blueprint's Compile button.

    Click for full image.

  2. 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.

  3. 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.

    creatingSets_Step13.png

  4. Go ahead and click the Add (+) button once again.

    creatingSets_Step14.png

    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. Step14_Warning.png

  5. Add three elements to MyStringSet , naming them Apple , Banana , and Cherry .

    creatingSets_Step15.png

  6. Now, add one more element, naming it Banana .

    creatingSets_Step16.png

    Unreal Editor will emit a warning if you try to add a new element with the same value as an existing element.

    Step16_Warning.png

  7. 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.

creatingSets_Step17.png

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.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss