A first-person shooter (like Robot Dynamite) needs a first-person character. In contrast to a full third-person humanoid character, all the player can see is the gun and possibly part of hands and arms of the character. However, if it is a multiplayer game, or even a single player game in which one can look in a mirror or a closed-circuit video, the full third-person humanoid character is visible.
In Part I, we created an Unreal Engine 4 project and added some assets needed to build a first-person character.
Now we shall create a character blueprint and add the third-person mesh to it. We shall make it a complete third-person character. In Part III, we shall add the First Person components to the character.
This post assumes you have already completed Setting Up a First-Person Character in Unreal Engine 4: Part I.
Create a Character Blueprint
- Re-open your Unreal Engine 4 editor project, “FirstPersonCharacter”. Load the blank level we created called “Overview”.
- In the Content Browser panel, in the top-level Content folder, right-click a blank area and select Blueprint Class in the Create Basic Asset section.
- The Pick Parent Class popup appears. Select Character as the parent class.
- A new blueprint appears in the Content Browser. Change its name to BP_Character.
- Double-click the BP_Character asset to open an editor for it.
- We can see a few things the Character class provides for us already: a capsule component for collision, an arrow component to show which way is forward, and a mesh component that currently is set to nothing at all. There is also a Character Movement component that lets the character walk, jump, and so on.
Add a Third-Person Humanoid Character Mesh
- In the Components panel, at the top-left (by default) of the blueprint editor window, select the Mesh (Inherited) component.
- In the Details panel (by default on the right), find the Mesh category, and the Skeletal Mesh property. Click the dropdown menu to the right of the icon and start typing “SK_Mannequin”. When you see the SK_Mannequin mesh appear in the menu, select it. A mannequin appears in the viewport with its feet at the center of the capsule.
Adjust the Mannequin
- The mannequin is placed wrong: it needs to face forward, and the feet need to be at the bottom of the capsule. The capsule is the wrong size too. We now fix this.
- Let us fix the capsule first. In the Components panel, at the top-left (by default) of the blueprint editor window, select the CapsuleComponent (inherited) component.
- In the Details panel (by default on the right), find the Shape category and change the Capsule Half Height to 96 and the Capsule Radius to 42. (In reality, you may need to do trial-and-error to make the capsule fit the character. These values are specific to the Epic Mannequin).
- Now, select the Mesh component again. We move the character down so the feet are at the bottom instead of the center of the capsule. The distance is exactly the capsule half-height. So find the Transform category, and change the Location Z value from 0.0 to -96.0.
Rotate the Mannequin
- The character is also facing the wrong way. So, with the Mesh component still selected, in the Transform category, change the Rotation Z value to 270.
- Looks good so far! Click the Save (looks like a floppy disk) icon in the menubar to save the changes to the blueprint.
- Return to the Overview level window. Drag the BP_Character asset from the Content folder of the Content Browser into the Viewport window to place the character on the floor. It should snap so that the feet are on the ground. We now have a third-person character, but no first-person mesh and it currently won’t do anything.
Add a Boom and Camera
We now add a camera that allows both behind-view third-person mode and the first-person view. The boom is a Spring Arm component that automatically retracts when it hits a wall to keep the character visible.
- In the BP_Character blueprint editor (if you closed and reopened it, you may have to click “Open Full Blueprint Editor”), find the Components panel (by default, top left) and select the CapsuleComponent (Inherited) component. Then click the green Add Component button. Start typing “Spring Arm”, and when you see the Spring Arm component in the menu, select it. Rename it “Camera Boom” since that is what we shall use it for.
- In the viewport (you may have to select the Viewport tab) you will see the camera boom, which looks like a red line (but it is invisible in the game). Select the Camera Boom component in the Components panel and click the green Add Component button. Start typing “Camera” and when you see it in the menu, select it. This time, leave its name as “Camera”.
- You now see a blue camera at the end of the boom in the viewport. Again, it is invisible in game. Also the boom is invisible when it is not selected. Now we make some adjustments.
- Currently, the camera is looking straight into the lower back of the mannequin. We need to adjust that. Select the Camera Boom component in the Components panel and find the Transform section in the Details panel.
- Set the Location property to X=-25.85, Y=17.97, and Z=44.23. These values were found through trial and error. The camera does not quite look out through the eyes, but it is a good place for aiming as it looks over the right shoulder (the Epic Mannequin comes with right-handed animations).
- For now, we make it a Third Person character (we add First Person functionality later). With the Camera Boom still selected, find the Camera section in the Details panel, and set the Target Arm Length property to 600 (so the camera follows about 6 meters behind, giving a good view).
Make the Character Work
Now, we add logic to the blueprint and register the BP_Character blueprint as the default character.
Animate the Mesh
- First, let’s animate the mesh. Select the Mesh (Inherited) component in the Components panel and in the Details panel, find the Animation section.
- Set Animation Mode to Use Animation Blueprint, and set the Anim Class to UE4ASP_HeroTPP_AnimBlueprint. In the Viewport panel, the mannequin now animates in an Idle posture.
Set as Default Pawn
- Now, let’s make it the default pawn: Click the Settings icon in the toolbar (looks like cogs), and select Project Settings.
- In the Project Settings window, select Maps and Modes from the left sidebar menu (in the Project section).
- Find the Default Modes section in the main content area, and find the Default GameMode property.
- Click the Plus (+) sign to create a new game mode. Name it FPS_GameMode and click OK.
- Click the rightward-pointing triangle to the left of the Selected GameMode property to open it up. Find the Default Pawn sub property. Select BP_Character from the dropdown to make it the default pawn. Close the Project Settings window and return to the Overview level.
- Delete the character we had previously placed in the level: we no longer need it. The Player Start actor, which looks like a game controller with a pennant, will spawn the character for us.
- Click the white right-facing triangle icon (Play) in the toolbar to play the level. You will be 6 meters behind the mannequin, but it cannot move yet. Hit ESC to stop.
- Normally, we would have to return to Project Settings and set up input, but importing the First Person Blueprint template did that for us already. So, there is no step 3.
Set up Movement
- Return to the BP_Character blueprint editor and open the Event Graph tab. For now, just delete the three starter nodes. They can easily be re-added later if we decide we need them.
- Now, set up the following blueprint in the event graph. When done, press the Compile icon in the toolbar (looks like a pair of cogs, and a question mark to indicate it needs to be compiled).
When you test it, some of the movements will work (WASD keys and mouse, Space to jump), but some won’t. We need to change some settings to fix this.
- Select the Camera Boom component in the Components panel in the BP_Character blueprint. In the Details panel, find the Camera Settings section. Make sure Inherit Pitch, Inherit Roll, Inherit Yaw, and Use Pawn Control Rotation all have their boxes checked. Press the Compile icon in the toolbar (looks like a pair of cogs, and a question mark to indicate it needs to be compiled). Now it works when you play-test!
- We add some camera lag to make it feel a little better. Select the Camera Boom component in the Components panel in the BP_Character blueprint. In the Details panel, find the Lag section. Check the boxes for Enable Camera Lag and Enable Camera Rotation Lag. Set Camera Lag Speed to 10, and Camera Rotation Lag Speed to 10.
- Play-test the level. We now have a third-person character! Remember to save your work.
In Part III we shall add the first-person arms to the third-person humanoid character and make it a character switchable between first- and third-person.
You must be logged in to post a comment.