Level Blueprint Communication

Unreal Engine 4 has a special type of Blueprint called Level Blueprint. Each Level of the game has a default Level Blueprint. They are useful for creating Events and Actions that only happen at the current level. To access the Level Blueprint, click the Blueprints button at the top of the Level Editor and choose the Open Level Blueprint option, as shown in the following screenshot:

In the Level Blueprint, we can easily create references to Actors that are on the Level. To see this in practice, let's create an example where Box Trigger is added on the Level. When an Actor overlaps the trigger, Blueprint_Effect_Sparks is activated, producing the effect of a spark:

  1. Create or use an existing project based on the Third Person template with the starter content.
  2. In the Level Editor, look at the Modes panel on the left. In the Basic category, there is a Box Trigger, as shown in the following screenshot. Drag the Box Trigger and drop it somewhere in the Level:

  1. Resize and place the Box Trigger in a location in the Level through which the player must pass. The following screenshot shows an example. The Box Trigger is hidden in the game:

  1. Confirm that the Box Trigger is selected and open the Level Blueprint by clicking the Blueprints button at the top of the Level Editor and choosing Open Level Blueprint.
  2. Right-click Event Graph and add the Event labeled Add On Actor Begin Overlap that is within the Add Event for Trigger Box 1 category, as shown in the following screenshot:

  1. Return to the Level Editor. In Content BrowserContent | StarterContent | Blueprints folders, open Blueprint_Effect_Sparks. On the Components tab, select the Sparks Component and in the Details tab, search for the auto activate attribute and uncheck it, as shown in the following screenshot. Compile Blueprint_Effect_Sparks:

  1. In the Level Editor, drag Blueprint_Effect_Sparks from Content Browser and drop it in the Level near the Box Trigger to create an instance.
  2. Confirm that Blueprint_Effect_Sparks is selected and open the Level Blueprint. Right-click on Event Graph and select Create a Reference to Blueprint_Effects_Sparks, as shown in the following screenshot:

  1. Drag from the Blueprint_Effect_Sparks blue pin of the node and drop it in the graph in order to open Context Menu. Search for activate and choose Activate (Sparks). Connect the white pin of the OnActorBeginOverlap (TriggerBox) Event to the white pin of the Activate Function, as shown in the following screenshot:

  1. Compile the Level Blueprint and click the Play button of the Level Editor to test the Level. Move your character to the location of the Box Trigger in order to activate the sparks.

In this example, we saw how to add references and Events to Actors in the Level Blueprint. This is the essence of Level Blueprint Communication.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset