How the player character works¶
The player is BP_FriendslopCharacter, a child of Character, driven by BP_FriendslopPlayerController. The character has no variables of its own. Everything it does is a component, and each component can go on your own pawn too.
- The character and its controller:
Content/MPFriendslop/Blueprints/PlayerCharacter/ - The components:
Content/MPFriendslop/Blueprints/ActorComponents/
This page is the map. The pages after it are the recipes.
The controller¶
BP_FriendslopPlayerController receives every gameplay key. It handles the five that belong to any pawn itself: move, look, jump, crouch and the pause menu. It only uses Pawn and Character functions for them, so it drives any Character you give it.
When the local player starts, it adds its mapping context and creates the HUD. These are its fields:
| Field | What it does | Shipped value |
|---|---|---|
Default Context |
The Input Mapping Context added for the local player, at priority 0 | IMC_Default |
Gameplay Widget Class |
The in-game HUD | WBP_Gameplay |
Recap Widget Class |
The end of run recap screen | WBP_RunRecap |
Pause Widget Class |
The menu shell opened on pause | WBP_MenuRoot |
Pause Page Class |
The page shown inside it | WBP_PausePage |
Loading Widget Class |
The loading screen, shown until the clock starts and the level is visible | WBP_LoadingScreen |
Every other key is passed to the component that owns the system, on the pawn it controls. The controller finds it with Get Component by Class and calls one of its functions. A pawn without that component, such as the spectator, simply ignores the key. The components read no key themselves, so they work on your own pawn with nothing to wire.
| Action | Component | Functions called |
|---|---|---|
IA_Interact |
BP_InteractionComponent |
BeginInteraction, UpdateHold, ReleaseInteraction |
IA_Sprint |
BP_StaminaComponent |
StartSprint, StopSprint |
IA_Grab |
BP_GrabComponent |
TryGrab, TryRelease |
IA_ScrollSlot |
BP_GrabComponent, then BP_InventoryComponent |
AdjustHoldDistance, CycleSlot |
IA_UseItem, IA_Reload |
BP_InventoryComponent |
PressUse, ReleaseUse, PressReload |
IA_DropItem, IA_SelectSlot |
BP_InventoryComponent |
Server_DropSelected, SelectSlotFromAxis |
IA_Ping, IA_PingDanger |
BP_PingComponent |
RequestPing, RequestDangerPing |
IA_Emote, IA_EmoteWheelPage |
BP_EmoteComponent |
OpenWheel, CommitWheelPick, StepWheelPage |
The one exception is the shop screen pointer: BP_ShopPointerComponent reads IA_Interact itself. To change a key, change it in IMC_Default. See The controls, and adding an input.
What the character is made of¶
| Component | What it does | Page |
|---|---|---|
ViewRoot > ViewCamera |
The first person camera, at eye height | Movement, stamina and the camera |
BP_ViewMotionComponent |
Head bob, sway, lean, landing dip, crouch smoothing, sprint FOV | same page |
BP_StaminaComponent |
Sprint, and what sprinting and jumping cost | same page |
BP_VitalsSystem |
Health and stamina values, damage and death | Health, damage and new vitals |
BP_DamageFeedbackComponent |
The hurt sound, camera shake and red screen edge on your own machine. The edge is WBP_DamageVignette in the HUD, bound to this component's OnDamageTaken |
same page |
BP_FootstepComponent |
Footsteps and landing sounds | Sounds, footsteps and surfaces |
BP_NoiseComponent |
The noise enemies hear | How the enemy AI works, and what it hears |
BP_InteractionComponent |
Looks for what you aim at and uses it | How interaction works |
BP_GrabComponent |
Picks up and carries physics objects, pulls levers | How grabbing works, and tuning the weight |
BP_InventoryComponent, BP_ConsumableComponent |
The item slots, and items that restore a vital | How items and the inventory work |
BP_ShopComponent, BP_ShopPointerComponent |
Buying from the shop terminal | Add an item to the shop |
BP_DeathComponent |
What happens when you die | Death, revive and the spectator |
BP_EmoteComponent, Face (a BP_FaceComponent) |
Emotes, and the screen face | Add an emote or a face |
BP_CosmeticVisualsComponent |
Draws the hat, accessory and pattern | How cosmetics work |
BP_PlayerColorTintComponent, BP_NameplateComponent, BP_PingComponent |
Player colour, the name above the head, pings | Player colours, nameplates and pings |
Three more components are not on the pawn: BP_CosmeticComponent and BP_PlayerColorComponent on BP_FriendslopPlayerState, and BP_SpectatorComponent on the controller.
The character also implements BPI_VitalManagerInterface. Other systems reach the vitals through its GetVitalComponent, never by casting to the character.
The native values¶
Walking, crouching and jumping are plain Character Movement. The template only adds sprint on top.
| Where | Field | Shipped value |
|---|---|---|
| Character Movement | Max Walk Speed |
200 |
| Character Movement | Max Walk Speed Crouched |
130 |
| Character Movement | Jump Z Velocity |
420 |
BP_StaminaComponent |
Sprint Speed |
500 |
ViewCamera |
Field Of View |
90 |
The eyes sit 168 cm above the floor: ViewRoot is 80 cm above the centre of an 88 cm half height capsule. Crouched Eye Height is also 80, on purpose, so traces that start from the eyes stay right when crouched.
The body is SKM_Robot_Courier, animated by ABP_FriendslopLocomotion. The local player never sees it: Owner No See is on and Cast Hidden Shadow is off. The other players see the body and its shadow.
Put it on your own character¶
There are two ways in:
- Keep the template's character, change the body. A child of
BP_FriendslopCharacterwith your mesh. Nothing is lost. - Your own Character Blueprint. You add the components you want. Each one works on its own, and a system you leave out is not there.
Keep the template's character, change the body¶
- Right click
BP_FriendslopCharacterand pick Create Child Blueprint Class. - In the child, select
Meshand setSkeletal Mesh Assetto your mesh. - Leave
Anim ClassonABP_FriendslopLocomotionif your mesh usesSKEL_Mannequin, the UE5 Manny skeleton. - Open
BP_FriendslopGameModeand setDefault Pawn Classto your child.
Your mesh has to carry the names the systems look for:
| Name on your mesh | Used by | On SKEL_Mannequin |
|---|---|---|
FlashlightSocket |
The flashlight in hand | On the skeleton, you get it for free |
ShotgunSocket |
The shotgun in hand | Only on SKM_Robot_Courier. Add it to your mesh, in the same place |
HatSocket (bone head), BackSocket (bone spine_04) |
Hats and accessories | On the skeleton, you get them for free |
FaceScreen (bone head) |
The Face screen |
On the skeleton, but not where the robot's screen is. Add FaceScreen to your mesh, on your character's face |
Bone head |
Where the head appears on death | Manny bone |
Material slot named M_Robot_Shell |
Player colour and pattern | Name your slot this way, or change Tinted Slot Names on BP_PlayerColorTintComponent |
A socket on the mesh wins over a socket of the same name on the skeleton. To move a hat, an accessory or the face on the robot, edit the socket on SKM_Robot_Courier, not on SKEL_Mannequin.
Your own Character Blueprint¶
The parent must be Character: the camera motion, stamina and landing all read Character Movement.
- Under the capsule, add a Scene Component at eye height, and a Camera under it, like
ViewRootandViewCamera. - On the camera, turn
Use Pawn Control Rotationoff.BP_ViewMotionComponentwrites the camera rotation itself. - Set
Base Eye HeightandCrouched Eye Heightto the height of that Scene Component. - On your body mesh, turn
Owner No Seeon andCast Hidden Shadowoff. - Add the components you want, from the table in What the character is made of.
BP_ViewMotionComponentneedsMotionset toDA_ViewMotion_Default, or it does nothing. - Add the interface
BPI_VitalManagerInterface. MakeGetVitalComponentreturn yourBP_VitalsSystem, and put inOnDeathwhat your pawn does when it dies. - Forward the events of the table below.
- Set
Default Pawn ClassonBP_FriendslopGameModeto your character. KeepBP_FriendslopPlayerController: it drives anyCharacter.
Warning
Leave Crouched Eye Height at the engine default and the camera still looks right, but every trace that starts from the eyes starts from the wrong height when you crouch. Interaction and grab then aim lower than the camera, with no error.
These are the whole event graph of BP_FriendslopCharacter. Copy the ones for the components you added.
| Event on your character | Call |
|---|---|
On Start Crouch, if locally controlled |
AddCrouchTransition on BP_ViewMotionComponent, with Scaled Half Height Adjust |
On End Crouch, if locally controlled |
AddCrouchTransition, with minus Scaled Half Height Adjust |
On Landed |
NotifyLanded on BP_FootstepComponent, and if locally controlled, ApplyLandImpact on BP_ViewMotionComponent with the velocity Z |
On Jumped |
NotifyJumped on BP_StaminaComponent |
OnGrabbed of BP_GrabComponent |
If IsAxisMode is true (a lever or a door), GetGrabAttachment, then LockView on BP_ViewMotionComponent |
OnReleased of BP_GrabComponent |
UnlockView on BP_ViewMotionComponent |
NotifyRunEnded and NotifyArenaStarted, from the interface BPI_RunControl added to your character |
EndBleedoutNow on BP_DeathComponent |
LockView makes the camera follow the lever or the door instead of turning the body.
Three pieces do not go on the pawn: BP_CosmeticComponent and BP_PlayerColorComponent live on the PlayerState, BP_SpectatorComponent on the controller. To replace those classes too, see Use your own game framework classes. The HUD needs nothing: each piece of WBP_Gameplay looks for its component on the possessed pawn, and stays idle when it is missing.
Use your own animations¶
ABP_FriendslopLocomotion only casts its owner to Character, so it runs on any character. Its two fields are in Settings|Animation: Standing Blend Space (BS_Locomotion_Standing) and Crouching Blend Space (BS_Locomotion_Crouching).
On SKEL_Mannequin:
- Put your clips in the samples of the two blend spaces. Or make your own, and set them in the two fields.
- For the up and down aim of the upper body, replace the samples of
BS_AimOffset_Pitch. - The jump and fall clips are set inside the
JumpandFallstates of theLocomotionstate machine. - Add
BP_FootstepNotifyat each foot contact of your walk and run cycles, withFoot Socketset tofoot_lorfoot_r. Other players hear your steps only where a clip carries it.
Keep the speeds in step with your clips or the feet slide: walk at 200, run at 500, crouch at 130 (the crouch clips play at a rate of 0.65).
If you write your own AnimBP instead, keep two slots: DefaultSlot after the locomotion, for AM_Land and any full body montage, and UpperBody, for the emotes and the third person reload. Implement BPI_HandIKSuspend as ABP_FriendslopLocomotion does: count PushHandIKSuspend and PopHandIKSuspend, and fade the hand IK out while the count is above zero. Without it, the left hand stays glued to the grip during reloads and emotes. What a held item gives the AnimBP is in Make a held item, its hold pose and hand IK.
For another skeleton, retarget the animations with Unreal's IK Rig and IK Retargeter, or build a new AnimBP on your skeleton. Every name of the socket table then has to exist on your skeleton or your mesh.
Where to go next¶
- Movement, stamina and the camera to tune speeds, sprint and the camera feel.
- Health, damage and new vitals to hurt, heal and add a vital.