GameUE4

UE4 Blueprint Introduction

By 13. September 2017 April 10th, 2018 No Comments

Creating our First Blueprint in a Single Click.

  • Make sure you have the target object selected in the World Outliner panel, and click on the blue Blueprint/Add Script button at the top of the Details panel. You will then see a path select window.
  • Choose Blueprints in the Blueprints folder, inside the ThirdPersonBP folder.
  • To open the Blueprint editor, double-click on this Blueprint in your Content Browser > ThirdPersonBP > Blueprints or with the Blueprint actor selected in the World Outliner open it with Ctrl-E or RMB > Edit …

Detecting a Hit

  • Click on the Event Graph tab above the Viewport window and delete all the default items.
  • To create our hit detection event, right-click on empty graph space and type hit in the search box. Select the Event Hit node when it appears in the search results to bring it on the empty slate. Event Hit triggers actions every time another actor hits the actor controlled by this Blueprint.
  • The Event Hit node has a number of output pins. The white triangle pin in the top-right corner of the node is the execution pin, which determines the next action to be taken. Now that we have the trigger, we need an action that changes the material. Click and drag a wire from the execution pin to empty space to the right of the node. In the search window that appears, make sure that the Context Sensitive box is checked. This will limit the results in the search window to only those nodes that can actually be attached to the pin you dragged. Type set material in the search box and select Set Material (StaticMeshComponent).

Swapping a Material

  • Once you have placed the Set Material node, it is already connected via its input execution pin to the Event Hit node’s output execution pin. This Blueprint will now activate the Set Material action whenever the Blueprint’s actor hits another actor. To set up the material that will be called when the Set Material action is on, make a copy of the initial material and change the colour, texture, etc.
  • In the Blueprint click on the drop-down field labeled Select Asset underneath Material inside the Set Material node to set the new material. In the asset finder window that appears, scroll to find the new material, click to attach it to the Material field inside the Set Material node.
  • Before a Blueprint can be saved and used, it must be compiled. Hit the Compile button in the top-left corner of the editor toolbar, and then click on Save. To test the Blueprint click on the Play button and try running into the actor you created.

Change the State on Leave (Begin / End Overlap)

  • With this hit detection setup the actor remains in the triggered state after the hit. If we want it to return it to it’s default state and have more control over how and where the collision happens, we can use the Begin / End Overlap nodes instead of the Event Hit. In our Blueprint delete the Event Hit node. In the Components tab choose > Add Component > Box Collision.
  • Switch to the Blueprint’s Viewport and move, scale, rotate the Box Collision to match the actor’s geometry. Switch back to the Event Graph. With the Box still selected go to the > Details tab > Events and click + at On Component Begin Overlap and On Component End Overlap. Connect the execution pin of the On Component Begin Overlap node with the execution input of the existing Set Material node.
  • Copy Paste the Set Material node and change the material in the pasted node to the default or another material. Connect the Static Mesh Component node with the Target input of the Set Material node. Connect the execution pin of the On Component End Overlap node with the execution input of the second Set Material node.

Adding Movement

  • To allow our target to move, we first have to change the actor’s Mobility setting to Moveable. This allows an object to be manipulated while playing the game. In the Blueprints window with the Static Mesh Component (Inherited) selected look at the Details panel. Underneath the Transform values, you can see a toggle for Mobility. Change this from Static to Moveable.
  • RMB click on the event graph canvas and type in > Add Rotating Movement Component. If you want to have a permanent rotation, RMB click and type Event BeginPlay. Connect the white triangle of Event BeginPlay with the white triangle input of the Add Rotating Movement Component.
  • If you want to use a trigger object instead, connect the output of the On Component Begin Overlap with the input of the Add Rotating Movement Component.
  • With the Add Rotating Movement Component selected you can change the speed at the Details tab > Rotation Rate. If you want to translate your actor, you can use the AddActorLocalOffset node.

Recording Gameplay with the Sequencer

  • In the top toolbar choose > Cinematics > Add Level Sequence. Specify a name and path. It will then show up in the World Outliner.
  • If there is a Camera Cuts track in the Sequencer, delete it. Create > + Track > Camera Cut Track. In this track add  a > + Camera. From the dropdown menu select the ThirdPersonCharacter as camera and make sure it covers the whole timeline.
  • If you closed your UE4 project and want to continue working with the Sequencer you need to RMB click on the sequence in the World Outliner and choose > Edit LevelSequence or press CTRL-E (double click doesn’t work here).
  • In the sequencer window click on the clapper board icon to open the Render Movie Settings Menu.
  • Use Video Sequence as Output Format, change Frame Rate and Video Resolution, disable Use Compression to avoid compression artefacts.
  • In the Cinematic tab make sure > Allow Movement, > Allow Turning, > Show Player are checked.
  • > Capture Movie and then use the WASD keys to navigate to the hotspots you have created.
  • Convert the output .avi file with Adobe Media Encoder to .mp4.