Adding Movement to a Third Person Character

In this tutorial we are going to look at adding movement to a third person character in the Unreal Engine. This is going to be using Blueprints and should get you started with some of the basic principles regarding the engine and how to move a character.

Create the Project

  • Open the Unreal Engine
  • Choose the Blueprint tab and select the Third Person game option
  • Select the location you wish to save your project to.
  • Click Create Project

You should then see the Third Person Project open in the Unreal Engine’s Editor

Setting Up a Custom Character

The Third Person game template comes with a pre rendered player character. We won’t be using it, instead we will be building our own character from scratch.

  • Select the Third Person Character in the World Outliner.
  • Press the Delete key.

In your Content pane at the bottom of the editor right-click and create a new folder. Call this one Character.

Inside this folder, we are going to create a Character blueprint.

Right Click and select Blueprint. Then choose the Character option. Name this Player_BP. You should then see the Blueprint open in the viewport screen.

Select the Mesh (Inherited) component – here we are going to add a Skeleton from our Starter Content.

Use the dropdown menu at the Details panel on the right hand side to choose a Skeletal Mesh.

The one I have chosen is the Mannequin (Skeletal Mesh). Once this is selected use the Transformation arrows to move it into place in the capsule collider so it looks like:

Rotate the Mesh by -90 degrees so that it is facing the correct way. Now Compile and Save.

Now we want to set this player as the default when we start the level. To do this we go into the Project Settings and to Maps & Modes.

In here we select the dropdown for Selected GameMode and change the Default Pawn Class to Player_BP

Now when we press Play on this level, we will be automatically be using this player. In order to see the player in the level we need to set up a camera object. Open the Player_BP tab again.

Adding a Camera to your Third Person Character

In the Player_BP viewport click the Add Component button and select Spring Arm, rename this to Camera Arm and set the Z axis on the Transform to 48. You will see that this moved the Spring Arm component to about midway up the characters back. This is the arm which we will now place the camera on.

To Add the Camera keep the Camera Arm component selected and go to Add Component, click this and add a Camera. This will slot the camera onto the Spring Arm. Everything should be in the correct position now. Remember to Compile and Save.

When you press play you should see the Camera at the players back – giving you a third person perspective.

Creating a Blueprint to Move our Third Person Character

Now we come to the part which is the most interesting in this tutorial. How to move our character with Controls. Open the Player_BP and open the Event Graph Tab. Right click an empty Space and add the Get Control Rotation node, from the Return value add a Break Rotator node. This will take the control rotation and break it apart to X,Y and Z co-ordinates. From the Z(yaw) we want to add a Make Rotator node. Make sure this is connected to the Z node of the Make Rotator as shown below

With our transform values collected we now want to make these a Vector from the Make Rotator node’s return value add a Get Forward Vector and a Get Right Vector. These will help control the Axis Movement.

From the Return value of the Get Forward Vector and the Get Right Vector add an Add Movement Input node. Plug the return value of the Forward and Right vectors into the two World Direction components in the Add Movement Input Nodes.

From the Add Movement Input nodes add an InputAxis Move Forward node and an InputAxis MoveRight node. Attach their Axis values to the Scale Values of the Add Movement Input node as shown below.

Enabling Mouse / Controller Look

The only thing that remains is enabling the ability to look vertically and horizontally with the mouse. This is done by the following blueprint code:

The Pitch controls the looking up or down due to positive or negative values coming from the mouse / Controller stick. Similarly the Yaw controls the looking left or right depending on the position of the mouse / Controller Stick.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s