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:
You can tick Use Custom Key Mappings to change the inputs to your liking in Project Settings>Engine>Input.
Under Movement, you can change the movement values of the character. How fast/slow to walk/run. How fast or slow to transition from crouching to standing, etc.
Under Footstep Settings, you can enable/disable footsteps and change the stride amount which is the distance you need to travel before the next footstep is played. Mappings is where you will add your custom footstep data to play your footstep sounds based on the surface the character is moving upon.
Under Camera Shakes, is where you will add your camera shakes that you create in blueprint or C++. The easiest way is to create a camera shake blueprint class and drag n' drop it into one of the options.
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.
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.
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.
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.
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.
.h File
.cpp 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 below).
I need help!
If you are still having issues getting this plugin to work, feel free to join the Discord Support Server and report what the issue is in the #first-person-character channel.