Introduction to Blueprints in Unreal Engine #Part 2

This is part 2 of an short introduction to Blueprints and the first part can be found by clicking here.

1. Creating a simple blueprint to show text on screen:

    1. Create a folder in Unreal Engine and call it Blueprints.
    2. Right click in the folder and at the top of the pop-up menu select Blueprint and from the options select Actor.
    3. Actor is a basic template and can be used for many types of blueprints, but not for a character or an actor with a movement component.
    4. Name it BP_Basic. (The BP is short for blueprints)
    5. Open the blueprint by double clicking on it.
    6. The Blueprint will have various options available with its UI.
      1. There are 3 tabs at the top.
        1. Viewport: For adding meshes, particles and various other visual elements for use in game.
        2. Construction Script: Runs a script only once at the start of play.
        3. Event Graph: Runs a script continuously throughout the game or whenever triggered. 
    7. For this simple Blueprint we will only use Viewport and Event Graph.

2. Viewport:

  1. In the top left hand side click on Add.
  2. Search for a static mesh.
  3. Select the static mesh component.
  4. On the Right hand side in details > in the static mesh box > select a cube. (Any cube will do)
  5. Now we have a simple cube mesh added to this blueprint.
  6. This has only been added so we know where the blueprint has been placed when its dragged into the level.

 

3. Event Graph:

  1. In the Event Graph there are 3 default nodes auto added as they are very commonly used.
  2. We only need to use Event BeginPlay. So the others can be deleted.
  3. Drag of Event BeginPlay and search for Print String.
    1. This node is very useful for testing purposes, but you will (likely) never use it for an actual in game element.
    2. Print string prints some text into the top left hand corner of the screen.
    3. We can use it to test if our node flows are working as anticipated.
  4. Now in the bottom left hand side.
    1. Click on the Plus Button
    2. And create a float variable.
      1. Rename it to ‘Duration’.
  5. Drag this on to the graph.
    1. Click the little drop down arrow in the Print string node.
    2. There is a Duration socket.
    3. Plug in the Duration variable into this socket.
    4. Press Compile.
    5. Now with the Duration Float variable selected – Add a 5 into the value in the right hand side details panel.
  6. Now drag the blueprint into your level.
    1. Press play.
    2. In the top left hand corner you will see ‘Hello’ text for 5 seconds.
    3. Congrats if this is your first every blueprint!
    4. Your graph should look like the below.  

 

Final Output on the level/map screen:

  1. The blueprint should be placed anywhere in the level.
  2. When you press play you should get some small blue text in the top left hand corner for 5 seconds saying Hello.

For further tutorials and insights please see the page or for how to rotate a cube using blueprints please click here!