First Person Character Plugin for UE4.20+

A basic first person character controller with head-bobbing and custom footstep sounds. Available on the Unreal Marketplace

How to get started

Once you've installed the First Person plugin for your engine version, create or open up a new C++ project (it won't work with a Blueprint project), go to Settings>Plugins or Edit>Plugins, click on Characters and enable the First Person Character plugin. You will need to restart the engine for the changes to take effect.

Once it has restarted, go to Window and select Modes. A new tab will appear. Click on the search box and type FPCharacter, it should automatically find it when you type the first few letters. Drag and drop FPCharacter into the scene. And there you have it, press play and you are now possessing the character.

You should now be able to look with your mouse, move around, jump, run and crouch. If you want to override the interact functionality, you will need to create a new child class from this plugin. Which is what we will do in the How to derive from this plugin section. For now, let me explain the settings and how to implement footsteps and camera shakes.

If you select the character and scroll down to First Person Settings in the details panel, there are a list of options you can tweak:

First Person Settings

To setup footsteps, you will need to create a Data Asset derived from FootstepData. To do that, right click in the content browser and go to Miscellaneous>Data Asset and select FootstepData.

Data Asset Dialog window

Name the data asset and open it. There will be a physical material and an array of sounds that you will need to fill out. So make a new Physical Material and import your sound files and add them in. This is the result.

Footstep Data

To make this work, assign the physical material to a material that you want to use (open a material, add the physical material you created and click save), then add your Footstep Data asset to the Mappings array in the character under First Person Settings>Footstep Settings. Repeat this process for every footstep data you create. Like this.

Footstep data added to footstep mappings

Press Play, walk around and you should have your footsteps playing! Enjoy using this plugin!

How to derive from this plugin

Before we create a new class derived from FPCharacter, we first need to modify the [PROJECTNAME].Build.cs file to include the FirstPersonCharacter module. To do that, open up your Visual Studio solution, go to Source>[PROJECTNAME] and open [PROJECTNAME].Build.cs. You will see PrivateDependencyModuleNames, it's empty. If you don't have this, just add it in under PublicDependencyModuleNames. Add "FirstPersonCharacter" inside new string, just like the image below.

Modified Build.cs file

Once that is done, save the file, close Visual Studio and close your Unreal project. Go to your Unreal project directory, delete .vs, Binaries, Intermediate folder. Right click on [PROJECTNAME].uproject, click Generate Visual Studio project files. Once that's done, double click on your .uproject file to open up your project, it will ask you to rebuild the binaries, click Yes. It will take about a minute or less, depending on your computer and how many source files you have. Now we can derive from this plugin!

Go to File>New C++ class, click Show All Classes, search for FPCharacter, click on it and press next. Name your class and press Create Class. If compilation is successful, Visual Studio will open up and show your newly created class. You can test that this works by overriding the Interact function like this. (To see a list of virtual functions, scroll down to Virtual Functions section)

.h File

Header file

.cpp File

Source file

Save, go back to UE4 and click compile. When that's done, drag MyFPCharacter from the content browser or from the Modes window, into the scene and click Play. When you now press [F] you can see in the console that it has been overriden! Make sure you have setup your input bindings in the project settings (Take a look at the input bindings above).

Interact function overriden

Virtual Functions

Interact()

Quit()

I need help!

If you are still having any trouble getting this plugin to work, feel free to contact me at elsaleh78@gmail.com and report what the issue is.