[go: up one dir, main page]

0% found this document useful (0 votes)
285 views29 pages

Fps Controller Documentation

The FPS Multiplayer Controller Documentation outlines a project designed for creating engaging first-person shooter multiplayer experiences, featuring customizable loadouts, weapon attachments, and high-quality animations. It details the blueprint components, data assets, and key functionalities necessary for game development, including player controls, health management, and interaction systems. The document also provides insights into the UI and save game mechanics for player loadouts, ensuring a comprehensive understanding of the project structure and capabilities.

Uploaded by

alrpreset
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
285 views29 pages

Fps Controller Documentation

The FPS Multiplayer Controller Documentation outlines a project designed for creating engaging first-person shooter multiplayer experiences, featuring customizable loadouts, weapon attachments, and high-quality animations. It details the blueprint components, data assets, and key functionalities necessary for game development, including player controls, health management, and interaction systems. The document also provides insights into the UI and save game mechanics for player loadouts, ensuring a comprehensive understanding of the project structure and capabilities.

Uploaded by

alrpreset
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

FPS MULTIPLAYER

CONTROLLER DOCUMENTATION

Intro
Welcome to the FPS Multiplayer Controller Documentation!

This project serves as a comprehensive example for building engaging FPS multiplayer
experiences.

Key Features:

● Customized Loadouts: Be able to choose unique loadouts tailored to your playstyle.


● Weapons with Attachments: Customize weapons with a variety of attachments.
● Procedural Aiming: System that allows us to integrate new weapon optics and iron
sights with ease.
● High-Quality Animations: more than 150 first and third person animations.
● Warehouse Environment: fully detailed environment with realistic assets.

We’ll start by exploring the blueprint components that are used in the project. Then, we’ll
delve into the main blueprints to provide a comprehensive understanding on how everything
works together. Finally, we’ll wrap up with a couple of tutorials that will empower you to
modify the project to your needs.
This project provides you with a solid foundation to explore the possibilities of FPS
multiplayer game development and take your creations to the next level.

Data assets
It's important to explain this first since we’ll use data assets to store important information
throughout the project like weapons, attachments or skins without using hard references, this
will allow us to have lots of weapons with lots of skins in the same game without loading all
of them at once.

In this example, we store important weapon information including a soft reference of the
weapon blueprint that contains the mesh and animations of that weapon.The only exception
is the icon, which is directly stored for faster menu access. However, for projects with many
weapons or large icon textures, on-demand loading is recommended and can be achieved
using the same logic as the rest of the variables.

There are 3 types of custom data assets in the project PDA_WeaponInfo for the weapons,
PDA_SkinInfo for the weapon skins and PDA_attachments for the attachments.

Blueprint Components
AC_Loadout

Variables
keep in mind that all the variables are private so the only way to access them is by using the
set and get functions.

CurrentLoadout: the loadout the player is currently using, saves the references to the
actual actor that we are going to use to be able to spawn it at any moment.
PlayerLoadouts: this is an array that saves all the custom loadouts that the player made to
be able to choose one or the other before spawning in the match. Uses the type
LoadoutData that uses data assets to store the info, these data assets use soft references to
be light and don't take too much memory.
PreviewLoadout: Used to show the preview weapon that is used when the player is editing
the loadout in the main menu.
SelectedLoadoutIndex: use this integer to get the correct index in the loadout array, this is
the value that we need to change if we want to select a different Loadout.
bEditingPrimaryWeapon- a boolean that indicates if we are changing the primary weapon or
the secondary weapon.
MaxLoadouts: In the loadout selection menu we can create new loadouts so we use this
variable to limit the amount of loadouts.

Important Functions & Events

Delete Loadout: Deletes a loadout slot.


ResetCurrentLoadout: Clear all the variables in current loadout so the garbage collector
can remove those from memory if they are not in use.
GetStatsFromAttachments: Get the stat value of one of the stats types, for example
damage or control.
GetCurrentAttachmentStats: Return all the stats of an attachment.
AddNewLoadout: Creates a new loadout slot with the default loadout values.
SaveLoadouts: to save all the loadouts in the player's computer.The save slot by default is
simply called “SaveSlot”.
LoadoutInit: uses the save game slot to load all the player loadouts.
SetAttachment: Sets a new attachment in the player loadout array.

AC_PawnInfo

Pawn Info stores information about the pawn that other players need to know in order to play
the correct animation. It also utilizes event dispatchers to trigger some code when the player
changes these specific variables.
Variables
● bRunning
● bAiming
● bShooting
● bUsingLethal
● bCrouching
● Leaning
● bChangingWeapon
● bInspectingWeapon

Event Dispatchers

● OnStartAiming
● OnStopAiming
● OnStartShooting
● OnStopShooting
● OnStartRunning
● OnStopRunning
● OnStartUsingLethal
● OnStopUsingLethal
● OnStartCrouching
● OnStopCrouching
● OnDamageDone

AC_WeaponAttachments
This component stores the references to the current attachments that a weapon is using.

Variables:
Optic
Magazine
Stock
Accessory
Muzzle
Underbarrel

All these variables are RepNotify and the OnRep function is used to attach the attachment
mesh to the weapon mesh for multiplayer games (and single player games too)

Attachments- this variable holds the attachments that the weapon will use, if the
attachment is null for any slot (optic, magazine,etc) the default attachment will be used
instead, this logic is done in the spawn attachment function.
DefaultAttachments- holds the default attachments of a weapon, a weapon must have a
magazine so it is important to set this variable when creating a new weapon.

Event Dispatchers
OnAttachmentCreated - used for the server to apply changes that those attachment apply
to the weapon, for example changing the total bullets if the magazine can hold more bullets
OnRepAttachment- Called when an attachment is replicated to the client and used to
update the visibility of that attachment, for example the attachment FPP mesh should be
invisible if the player uses third person.

AC_InteractionSystem

This component will use a line trace every 0.1 seconds in front of the player to check for
interactables, if the line trace collides with an actor with the “I Interactive” interface the player
will be able to interact with that actor, we can set the description and the interact time of that
actor thanks to the functions that come with the interface.
The component will create a widget automatically to show the item description and the key
needed to interact with that actor.
To create a new interactable actor, just create a new actor, add the “I Interactive” interface
and set the Interact time and the description of the actor.

AC_ControllerSettings

The controller settings component only saves player preferences, like showing the FPS or
the latency. Pressing F1 shows the FPS on the top left corner of the screen and F2 the
Latency.

Variables
● bUseTPP
● bShowFps
● bShowLatency
AC_Health

Stores the health of the player. In this project you can’t die, nothing can damage the player
but the code is needed for other features and having this as a placeholder helps to extend
the project. For example, there is code to hide the UI if the player dies.

Event dispatcher On Health Changed


Called when the health changes, perfect to use in a health bar to update it.

Event dispatcher OnPlayerDead


Useful to remove widgets on dead, drop important items for a game mode or stop
representing a player on the minimap.

Main Classes

PlayerController Blueprint
In the player controller we are going to use the components UI_Manager to handle the UI,
controller settings component to save some player preferences there and lastly the Loadout
Componen where we can store all the information about the player loadout.

When the player wants to spawn the server will run the logic to set the selected loadout and
after that all the soft references will be loaded so the inventory component can create all the
weapons and attachments for the pawn that is getting controlled by this controller.

There are two macros that handle the loading of assets:

LoadSelectedLoadout: this macro loads the weapon set it as primary or secondary weapon
and then uses the other macro LoadAttachments to load all the attachments for the weapon

LoadAttachments: this macro just loads the attachments references converting the soft
references to hard references and stores the class in the CurrentLoadout variable from the
AC_Loadout to be able to create the actor on demand.
PlayerCharacter Blueprint
The Player Character blueprint is the biggest blueprint in the project since it has the logic for
the pawn movement and every other action that the player can do, like running, aiming,
crouching, jumping, etc.
This blueprint uses a couple of components like PawnInfo, InventorySystem, Interact System
and HealthComponent.

PawnInfo stores variables for the state of the pawn, for example if the pawn is crouching,
running, firing the weapon, etc.

InventorySystem will hold the information about the current equipment of the player, the full
loadout, perks (if needed) and ammo.

Interact System allows the player to interact with other actors that use the interact interface,
in this project is used to pick up weapons and ammo.

HealthComponent stores the health of the player. In this project you can’t die, nothing can
damage the player but the code is needed for other features and having this as a
placeholder helps to extend the project. For example there is code to hide the UI if the player
dies.

Replicated Movement logic


For the movement logic this project takes the player input and scales the final value based
on the movement type, that means that running will be 100% of the player speed
(maxWalkSpeed) and walk would be 62% of the max player speed, this values can be
changed at “Calculate Movement Input”. Using this method allows us to change the player
speed using the movement component prediction system so the player wont experience
server corrections like if we were just changing the max walk speed speed directly. This
method is only used because the project is 100% blueprints but there are better methods if
your project uses c++.

Base Attachment Blueprint


The BP_BaseAttachment will be used by all the attachments and has 2 important functions
that it's important to know, this functions are Get FPP mesh and Get TPP Mesh, in the base
class these functions are empty so we will need to override them in each attachment type
connecting the FPP mesh and the TPP Mesh to the respective output. This is needed
because the attachments can use static meshes like a muzzle or a foregrip or a skeletal
mesh, like the magazine since this one should be animated.
Variables:

Type: the attachment type that we are using.


Socket: The socket name that will be used to attach it to the weapon
Attachment Name: Name of the attachment in particular

Player State Blueprint

Used to store how many bullets the player fired and to calculate the accuracy for the
minigames good place to hold experience points, and other metrics.

BaseWeapon Blueprint
The main blueprint for all weapons is “BP_BaseWeapon” and all weapons should inherit
from this class, even melee weapons, and it will store all the montages for first person and
third person (except the ones that depend on the foregrip or the magazine), the rest of the
animations will be included in the animation layer for that weapon. There are lots of variables
that can be set in the base weapon blueprint that allows you to create different weapons
from a shotgun to a sniper rifle, changing a few parameters.

Important Variables
● AmmoPerMag
● ActualAmmo- used to save the ammo in case someone picks the weapon from the
floor.
● Damage
● Fire rate
● WeaponName
● WeaponRange
● WeaponSpread
● WeaponVerticalRecoilMax
● WeaponVerticalRecoilMin
● WeaponHorizontalRecoilMax
● WeaponHorizontalRecoilMin
● AmmoType
● Bullets Per Burst - only for weapons that have burst mode
● Bullet Velocity
● Firing Modes (list of firing modes of that weapon, can be auto, semi and or burst)
● Actual Firing Mode (The weapon will start with this mode)
● AimingFOV - used to know how close the FOV gets while aiming, 90 is the default
FOV of the camera.
● Weapon type, used to determine the animations to play on the animation blueprint
● HasSuprresor - to appear in the compast or not after shooting

Weapon Transform / Offset


To place the weapon on the pawn hands we use the weapon_r bone so we need to place
that bone with some offset to place the gun correctly. It is important to know this offset or
transform. Once we know the correct offset we need to apply that offset to each animation
that we are going to use with that weapon. To apply the transform there is an editor utility
blueprint that we have to run on the animation called “EUBP_SetWeaponR_Offset”, if we
open the blueprint we will find a variable called “Weapon Offset” we only need to set that
value to the weapon offset for our weapon, then we have to right click an
animation->ScriptedAssetAction-> SetWeapon_r_Offset that will set the weapon r bone to
the right position for each frame of the animation. You can do this with one animation or you
can select them all and run the utility script.

Firing Modes & Actual Firing mode


In the array Firing modes you can add the firing modes that weapon is able to do

Preview weapon
The preview weapon is used to represent the player weapon and attachment selections in
the loadout menu, when the player hovers over an attachment the preview weapon gets
updated to represent those changes.

Pickup Weapon
The pickup weapon is a representation of the player weapon that spawns when a player
drops the weapon, the server creates all the attachments and the client will update the
weapon and the attachments using on rep functions.
FPP Animation blueprint
For both first person and third person animations the structure is the same, the main
blueprint will be the ABP_Base_FPP or TPP with all the logic, then we have the
ABP_FPP_LayerAnims_Base that contains all the interface implementations, this just means
that there is some code that decides what animation to run, this blueprint only contains code
but there is no reference to any specific animation, the place to set those animations is in a
child blueprint of the ABP_FPP_LayerAnims_Base for each weapon, for example
ABP_FPP_AssaultRifle_Layer contains the rifle animations.

In the interfaces ALI_FPP_Anims and ALI_TPP_Anims you can create new animation
layers that you can implement in the ABP_FPP_LayerAnims_Base blueprint in case you
need to add something.
To add a new weapon we only need to duplicate one of the weapon layers and replace the
animations for the correct ones and then set the new layer in the weapon blueprint, keep in
mind that the changes only take effect if you set the animations in the details tab and not the
anim Preview Edit tab.

Left hand pose


It is important to set the left hand pose always since the project uses more than one foregrip
and the left hand is not always in the same position. To get the left hand pose there is a
function called GetLeftHandPose that gets that information from the foregrip blueprint and if
the attachment does not exist it takes the value from the weapon blueprint directly, this
means that we need to set the default left hand position in the weapon and each specific
hand pose for his respective attachment.
AutoAim

The AutoAim feature allows you to use any weapon scope, ironsight and automatically align
the camera with weapon sight with the camera. For this feature to work we only need to
place a socket called “aimSocket” in the skeletal mesh of the weapon or the attachment that
we want to use to aim. You can move it around to get the Y axis to control how close the
camera will get to the AimPoint, there is an offset in the autoaim code that will be added to
the Y value and that will be the final position of the camera.
TPP Animation blueprint
The main difference with first person animations is that all the lower body animations except
the running animation are the same so the only animations that we need to set in the
weapon layers are the upper body animations that will layer with the lower body ones.

For the left hand pose is the same function as the first person animation blueprint, the
default pose will be stored in the weapon and the foregrip will hold the necessary pose for
that attachment in particular.

Loadout Code
First we set the variable player loadout where all the custom loadouts are saved, then after
clicking spawn we load all the necessary assets and save those classes in a variable called
Current Loadout, this variables uses the classes and not soft references like the player
Loadout variable
Save Game
The save game is used to hold the loadout information of that player, so the player can
modify each loadout individually and get saved between sessions, this save file is stored
locally in the user's computer.

UI
Loadout UI

WB_LoadoutSelection lets the player choose a loadout, create and delete loadout. In this
widget you click the edit weapon button to change the attachments and skin or click on the
weapon button to change the weapon itself.

Weapon stats
The weapon stats change when the player cursor hover over an attachment to see the
difference in the values, these values are not connected to anything by default.
Tutorials

Adding New Weapons

1. Creating the new weapon blueprint

Create a child blueprint of Base Weapon (you can duplicate a weapon that will be
similar to the new one to save time)

2. Setting the variables, animations, sounds and visual effects

In the new weapon blueprint change the skeletal mesh and custom variables, make
sure that you use a similar weapon as the base so all the variables have something
set by default, for example the dry fire sound, the crosshair or muzzle emitter can be
the same.
Important variables:

FPP weapon Anims: animation layer with all the animations for the weapon
TPP weapon Anims: same thing but for the Third person
Default FPP Left hand pose: this allow us to use different foregrips without having
to duplicate every animation changing the left hand position
Default TPP Left hand pose: same thing but for the Third person
Animations: In the weapon blueprint we hold the montages for that weapon and the
animations for the weapon body itself.

Set the montages for the weapon (Reload, Inspect, Fire animation…) remember that
if you change a montage the new montage must use the same notifies, so before
replacing one montage open it to check if there is a notify, for example in the reload
montage we will need a reloadCompleted notify.

3. Animation Layer

Change the animation layer for that weapon, inside the layer you will have to replace
all the animations.
4. Data asset

Create a Data asset child of “PDA_WeaponInfo” and fill the information. For the
weapon name you will have to change the "E_WeaponNames” enumeration to be
able to see your weapon in the list.
5. Weapon Attachments

Click in the weapon attachments component and set the default attachments for your
new weapon, the only one needed for the weapon to work is the magazine so your
weapon should have the magazine as a separate mesh.

If you want the weapon to have attachments add this weapon to the” compatible
weapons” array in each attachment that you need and make sure that
CanUseAttachments variable from the previous point is set to true.
If you create a new attachment check the blueprint to see what variables do you
need to set, for example a foregrip will need the left hand pose and a magazine will
need a new reload montage.

6. Weapon Sockets

Create the sockets for the attachments, the muzzle flash and the “aimsocket” in the
new skeleton. You can modify the sockets in real time so just run the game and move
the sockets until you have it in the right place.

7. Making the weapon appear on the menus

Finally add the weapon in the “Weapons” array in “O_WeaponList” Object to make it
appear in the loadout menu.
Adding New Attachments
1. Create a child blueprint dependent on the attachment type, if you are creating a new
type entirely just use base attachment as the base class.
a. BP_Base_Optics
b. BP_Base_Underbarrel
c. BP_Base_Accesory
d. BP_Base_Mag
e. BP_Base_Muzzle
f. BP_Base_Stock
2. Change the skeletal mesh for FPP and TPP and set the variables, if it is a mag you
will need to change the reload montage that will be stored inside the attachment, for
the muzzle you might need to change the Fire weapon sound, if it is a suppressor.
3. Create a Data asset child of PDA_AttachmentData and fill the information.
4. Add the attachment to the “O_WeaponList” Object to make it appear in the loadout
menu.
5. If the attachment is an optic you will need to create a socket called aimSocket in the
middle of the optic, you can move in the X axis the socket in real time even when the
project is running to adjust the distance.

Adding a new trial minigame

1. Place the BP_trial on the level, that will let you create the first trigger that will start the
trial
2. Place all the targets (Bp_Target and BP_Target_Small) and the rest of the triggers
(default triggers volumes)
3. Click the BP_Trial actor open the target list and add the targets using the pick actor
from scene tool

4. Add the triggers to the trigger list, the order is important, pick them from start to
finish.
5. Select each target on the target list and set the Trial Stage variable, if the value is 1
they will be active from the start, if the value is 2 they will be active after crossing the
first trigger, 3 for the second trigger and so on.
6. Pick the End trigger to finish the trial.
7. Pick a reset volume that will reset the trial.

Adding a new Shooting range minigame

1. Place the BP_ShootingRangeMinigame actor on the level and set the trigger volume
that comes with it, this volume will start the minigame.
2. Place all the targets.
3. Click the minigame actor and pick the targets using the pick actor from scene tool

4. Set the “Session Total Targets” variable, after that amount of targets has been
activated the minigame will end.

Retargeting a metahuman

First we are going to migrate the metahuman kellan, it is the one used in the
GameAnimationSample Project made by Epic. Make sure that you migrate the body and the
rest of the components that you want to add like the head, feet, legs, etc.
IK retargeter
For the Ik retargeter we need to create the Ik retargeter itself, and one IK rig for the
metahuman skeleton the IK rig for the default UE5 mannequin comes with the project.

Create the IK rig and call it “IK_Metahuman”, set the preview skeletal mesh
(m_med_nrw_body) and click “Auto Create Retarget Chains” and “AutoCreate IK” then close
the IK rig.

These buttons only exist in UE5.4

Crete the IK retargeter and call it “RTG_Metahuman” and set the Ik rigs and the skeletal
meshes like in the picture
Then change the “Target Mesh Scale” to 1.0525 and the result will be 1:1.

Animation Blueprint

Create a new animation blueprint called “ABP_Retarget_Metahuman” that uses the


metahuman skeleton and connect the “Retarget Pose Form Mesh” node to the “Output
Pose” node.
Click on the retarget node and set it up like this.

Once we have all this, create a child blueprint form BP_PlayerCharacter and we will need to
add a couple of skeletal meshes so we have something like this.
Then go to the construction script and add these nodes
The MetahumanBody_FPP will run the animation blueprint that copies the MeshFP
animation blueprint and the rest of the components will use the set leader pose Component
to follow the MetahumanBody_FPP animation blueprint.

Then we will have to do the same with the TPP skeletal mesh and the Legs for the First
person perspective.
Set all the skeletal meshes in their slots and remember to set the animation blueprint
“ABP_Retarget_Metahuman” in the MetahumanBody_FPP and MetahumanBody_TPP.

Override the two functions GetFPPMesh and GetTPPMesh and change the output to the
MetahumanBody_FPP and MetahumanBody_TPP meshes

Now we have to set visible to false to the original meshes (MeshFP, and Mesh), set cast
shadow to false for the new first person skeletal meshes (MetahumanBody_FPP and
Torso_FPP) and set owner no see for true for all the new Third person meshes and lastly set
hiddenShadow to false for the original skeletal mesh called “Mesh”.

For this specific mesh we can scale to 1.0525 so it looks as close as possible as the default
mannequin, set this new scale for the MetahumanBody_FPP and the MetahumanBody_TPP.

Change the default pawn class in the BP_GM to the new player character child blueprint.

We should be done and I should look like this after setting all the materials correctly.
Every retargeting is different, if you are using another skeleton you will have to play around
with the values until you get something that works, there are some skeletons that are pretty
difficult to retarget like the UE4 mannequin because the hands are too different so the result
is not 1 to 1. If you use a custom skeleton and the result is not good enough you can always
retarget the animations and modify them one by one to fix the problems, this will take some
time but it's better than doing all the animations from scratch.

How to report a bug

If you find a bug in the project, contact me via email gonzalo.deleitoh@gmail.com or on the
Discord server Discord Server and let me know to reproduce the error in a default project so
I can fix it as soon as possible.

Do you need more help?


Feel free to contact me via email or on the discord server and I will help you.

You might also like