Inside your project on the Main Toolbar, click the Blueprints button then select Open Level Blueprint.
The Level Blueprint is a specialized type of Blueprint that is unique to each level and acts as a level-wide global graph.
Right-click in the graph and search for and add the Spawn Actor from Class node.
This will enable us to define the thing that we want to spawn by specifying the class (or type of object) we want to spawn.
In the Class section of the SpawnActor node, select the Blueprint_Effect_Fire class.
This is a Blueprint Class that was created as part of the Starter Content pack enabled when creating the project.
Right-click in the graph and search for and add the F Keyboard Event.
This will be the key that we will use to spawn and destroy our fire effect.
Right-click in the graph again and search for and add the Flip Flop node.
This node acts as a switch where the first time we enter it we will execute the A pin and the second we enter this node will execute the B pin.
Once executing the B pin, the next time we enter we will execute the A pin again and "flip-flop" back-and-forth between the A and B pins.
Left-click and drag off the Pressed pin of the F node and connect it to the Flip Flop and Spawn Actor nodes.
This will enable us to execute (when F is pressed) the call to the Spawn Actor node to spawn in our Blueprint Fire effect.
Right-click in the graph and search for and add the Destroy Actor node.
With this node we can destroy any Actor we specify.
Connect B pin of the Flip Flop node to the Destroy Actor node.
The second time we press F, the B pin on the Flip Flop will be called and will execute the Destroy Actor node.
The Destroy Actor has a Target input pin, instructing the node what it is to destroy.
By default, it is set to Self and in this case is a null pointer, meaning it is unclear what it is to destroy as the Level Blueprint cannot be destroyed.
If this Destroy Actor node were sitting inside our Character Blueprint and we instructed it to target Self, then our Character would be destroyed.
In this case, we need to tell the Destroy Actor node what it should be destroying (our Blueprint Fire effect).
To do this we will need to create a reference to the Blueprint Fire effect that we spawn.
Right-click on the Return Value of the Spawn Actor node and select Promote to Variable.
The Return Value, in this case, is the "thing that we spawn" and what we want to store a reference to so that we can destroy it later.
In the Details panel for the variable, give it a name such as CurrentFlames.
In the MyBlueprint panel under Variables, hold Ctrl then drag-and-drop the CurrentFlames variable into the graph and connect it to the Target of Destroy Actor.
We are now instructing the Destroy Actor node to target our variable reference to the Blueprint Fire effect we created.
Right-click in the graph and search for and add the Get Player Character node.
This enables us to locate the designated player character so that we can access and obtain information about the character.
Off the Return Value of Get Player Character, search for and add the Get Actor Transform node.
This will tell us the Location, Rotation and Scale of our player character and we will use this to define the spawn location of our Blueprint Fire effect.
Connect the Return Value of the Get Actor Transform to the Spawn Transform on the Spawn Actor node.
Click image for full view.
Our graph at this point is almost complete and we designated that when we press the F key that we will spawn in our Blueprint Fire at the location of our player and store it as a variable.
When we press F a second time, we will then destroy that variable that we created (killing off the fire effect). The last thing that we will do is attach the fire effect to our player.
Currently when we spawn in our fire effect it will spawn at the location of our player, however, if the player moves around the fire will stay in the location in which it was spawned.
Left-click and drag off the reference pin on the Set node and search for and add the AttachToActor node.
With this node we can attach the fire effect to another Actor, in this case, we will want to attach it to our player character.
Use a Get Player Character node and attach as shown below, setting the Location Rule and Rotation Rule to Snape to Target.
Click image for full view.
Here we are stating that we want to attach the reference variable for our fire effect to the player character, snapping its location and rotation to match the player character.
Click the Compile button to compile the Blueprint.
Return to the main Level Editor window, then from the Main Toolbar click the Play button to play inside the editor.