How to Create a Simple FPS in Unreal Engine 5

In this Unreal Engine 5 tutorial, you’ll create a simple first-person shooter while learning how to create a first-person character equipped with a gun, and you’ll learn how to apply damage to other actors in your game. By Ricardo Santos.

4.5 (2) · 2 Reviews

Download materials
Save for later
Share
Update note: Ricardo Santos updated this tutorial for Unreal Engine 5. Tommy Tran wrote the original.

A first-person shooter (FPS) is a genre where the player uses guns and experiences the game through the eyes of a playable character. FPS games are immensely popular, with such well-known franchises as Call of Duty and Battlefield.

Unreal Engine was built to create FPS games, so it makes sense to create one using it. In this tutorial, you’ll learn how to:

  • Create a first-person Pawn that can move and look around.
  • Create a gun and attach it to the player Pawn.
  • Shoot bullets using a line trace — also known as a raycast.
  • Apply damage to actors.
Note: If this is your very first time using Unreal Engine, head over to our Getting Started tutorial to learn how to download the editor and navigate the interface.

Getting Started

Download the project materials with the Download Materials button at either the start or the end of this article, and unzip it. Navigate to the project folder called BlockBreakerStarter 5.0, and open BlockBreaker.uproject. You’ll see the following scene:

Initial view of the project on Unreal Engine 5 main window.

The green wall consists of multiple targets that turn red when they take damage. Once their health reaches zero, they disappear. The red button resets all the targets.

First, you’ll create the player’s Pawn.

Creating the Player Pawn

If you’re coming from UE4, you might’ve noticed that the folders panel seems to be missing. Despair not, as it’s hidden to allow an almost full-screen view of the project. To find the project folders, just click Content Drawer in the lower-left corner of the screen.

Content drawer in the lower-left corner of the screen.

Now, you can see the navigation panel, complete with the folder structure and game assets. If you’d like to have it permanently open at the bottom of your screen, simply click Dock in Layout on the right of this panel.

Content Drawer panel with Dock in Layout highlighted.

Navigate to the Blueprints folder and right-click the panel background to create a new Blueprint Class. Select Character as the parent class and name it BP_Player.

Creating a blueprint class in UE5

Character is a type of Pawn with additional functionalities, such as the CharacterMovement component that automatically handles movement like walking and jumping. You simply call the appropriate function, and it moves the Pawn. You can also set variables such as walk speed and jump velocity within this component.

Selecting Character Movement.

Before you can make the Pawn move, it needs to know when the player presses a movement key. To do this, you’ll map movement to the W, A, S and D keys.

Note: If you’d like to know about mappings, you can learn about them in this Blueprints Tutorial. Key mapping is how you define which keys will perform actions.

Creating Movement Mappings

With key mapping, you can alter an attribute of the player character — such as their position in the X-Y plane or the camera angle of the viewport — and apply it in the game world. This is how you manipulate character displacement and viewing angle.

Select Edit ▸ Project Settings and open the Input settings under the Engine section.

Project settings screen

Add two Axis Mappings by clicking the + next to Axis Mappings twice. You may have to expand the Axis Mappings list by clicking the expand triangle in front of Axis Mappings that appears after you add the first mapping. Rename them MoveForward and MoveRight. MoveForward will handle moving forward and backward. MoveRight will handle moving left and right.

Input menu where the key bindings are defined.

For MoveForward, change the key to W by first selecting the None dropdown list. Then, expand the Keyboard list, and finally, select the letter W right at the bottom of that list.

Key mapping

After that, create another key by clicking the + next to MoveForward, and set it to S. Change the Scale for S to -1.0.

Adjusting the scale in the key mappings, to move forward, the scale is 1.0 and to move backward, -1.0.

Note: If you’d like to learn more about the Scale field, you can refer to the same Blueprints Tutorial mentioned above. The Axis Value and Input Scale section describes what it is and how to use it.

Later, you’ll multiply the scale value with the Pawn’s forward vector. This will give you a vector that points forward if the scale is positive. If the scale is negative, the vector points backward. Using the resulting vector, you can make your Pawn move forward and backward.

Line graph showing how the scale value influences on the Character movement.

Next, you need to do the same for moving left and right. Change the key for MoveRight to D. After that, create a new key and set it to A. Change the Scale for A to -1.0.

Adjusting the scale in the key mappings, to move right, the scale is 1.0 and to move left, -1.0.

Now that you have the mappings set up, you need to use them to move.

Implementing Movement

Double-click BP_Player to open it, and you’ll see the Viewport view. Navigate to the Event Graph using the tabs at the top of the window.

EventGraph tab location on the UE5 editor window.

Right-click the view background to add a MoveForward event, the one listed under Axis Events. This event will execute every frame, even if you don’t press anything.

Creating the MoveForward blueprint node by right clicking on the screen background.

It also outputs an Axis Value, which is the Scale values you set earlier. It outputs 1 if you press W and -1 if you press S. If you don’t press either key, it outputs 0.

Move forward event node.

Next, you need to tell the Pawn to move. Add an Add Movement Input, and connect it like so:

Connecting the nodes to apply movement to the character.

Add Movement Input takes a vector and multiplies it by Scale Value, converting it to the appropriate direction. Since you’re using Character, the CharacterMovement component will move the Pawn in the appropriate direction.

Now, you need to specify which direction to move. Since you want to move forward, use Get Actor Forward Vector to return a vector pointing forward. Create one and connect it like so:

Setting the directions the character will move.

So, to summarize:

  • MoveForward runs every frame and outputs an Axis Value. This value is 1 if you press W and -1 if you press S. If you don’t press either, it’s 0.
  • Add Movement Input multiplies the Pawn’s forward vector with Scale Value. This causes the vector to point forward or backward, depending on which key you press. If you don’t press any key, the vector doesn’t have a direction, meaning the Pawn doesn’t move.
  • The CharacterMovement component gets the result from Add Movement Input and moves the Pawn in the appropriate direction.

Repeat the process for MoveRight, but replace Get Actor Forward Vector with Get Actor Right Vector.

The result after applying the same process to the moveRight event.

Before testing the movement, you need to set the default Pawn in the game mode.