Share
Explore

Replicated Sprinting, Crouching and Sliding

Introduction
This project allows you to easily and quickly add fully replicated and animated Sprinting, Walking, Crouching, Sliding and Foot IK toggle-able abilities through Blueprint Actor Components.

Features
Customize it, Make it yours - Allows you to customize the system even in real-time.
Plug & Play - Simple Actor Components to be initialized and the rest is history.
Simple Blueprints - The entire system is in blueprints, coded with optimized industry standards. It is also compatible with C++.
Fully Replicated - The entire system is replicated over the network and can be played in multiplayer.
Sprinting - Modifiable sprint speeds for normal and crouched states.
Walking - Modifiable walk speeds for normal and crouched states.
True Crouching - Replicated crouching with reduced collision.
Sliding with Root-motion - Slide with root-motion animations. You can also tune the rotation rate to be able to turn during the slide!
Sliding with Interpolation - Don’t want to use root-motion? No big deal. Use our optimized custom-made interpolation system and avoid all the overhead of Timelines and Component managers! You can also tune the rotation rate to be able to turn during the slide!
Foot IK System - A simple Foot IK Component that is easily removable. Adjusts feet locations and rotations to slopes.

Controls
1.Controls.png
Initial Setup

Locomotion Setup
The project comes of course with its own character class ready for usage for those who want to start a fresh project. Nonetheless, adding the components to your own character classes is as simple as ABC.
Open you character blueprint
Click on Add Component
Search for and select BP_InterpolationComponent
image.png
Initialize it in the construction script ❗BEFORE THE OTHER COMPONENTS❗
image.png
Search for and select BP_LocomotionComponent
2.AddBP.png
6. Initialize the components in the Construction Script or On Begin Play by using the OnInitialize function of the corresponding component and plugging in the character (Reference to self). You can also copy these scripts from our BP Character class
image.png
7. Plug in your inputs. You can either define these in your Project Settings under Input or directly use the Input Event Keys for testing. You can also copy these scripts from our BP Character class
4.Inputs.png
8. Add a DefaultSlot to your AnimBP in order to play animation montages
5.DefaultSlotAnimBP.png


Foot IK Setup
If you are using a character rigged to the Unreal Mannequin, you can use our ThirdPerson_AnimBP_IK to save you some trouble. Nonetheless, adding Foot IK to your own character classes is extremely simple.
Open you character blueprint
Click on Add Component
Search for and select BP_IKComponent
2.AddBP.png
4. Initialize the components in the Construction Script or On Begin Play by using the OnInitialize function of the corresponding component and plugging in the character (Reference to self). You can also copy these scripts from our BP Character class
3.InitializeBP.png
5. Select the BP_IKComponent from the Components Panel and set up the following attributes in the Details Panel:
Right/Left Foot Bone Name : Name of the bone of the feet in your character rig
Right/Left Foot Joint Target Location : Specifies where the knee will aim when IK is active. Default value works well with UE4 Mannequin but play around with values for your specific rig.
Max Foot IK Pelvis Offset : The maximum amount by which the pelvis can be offset to compensate the foot IK
Feet General Offset : A constant that is added to the feet offset to avoid them clipping through the floor

⚠️FOR THE NEXT STEPS, YOU CAN EITHER USE OUR ANIMATION BLUEPRINT OR COPY ALL THE SCRIPTS FROM OUR ANIMATION BLUEPRINT OR YOU CAN FOLLOW ALONG ⚠️

6. In your AnimBP, get the IK Component and promote it to a variable. You can also copy this from ThirdPerson_AnimBP_IK
IK4.AnimBPGetIK.png
7. In your Event Blueprint Update Animation event, get the IK Component variable you have just created and get all its attributes in order to promote them as variables. We strongly suggest copying the scripts from ThirdPerson_AnimBP_IK
IK5.AnimBPGetValues.png
8. In the AnimGraph of your animation blueprint, add the following nodes
IK6.AnimBPIKNodes.png
Two Bone IK Nodes : One for left foot bone and one for right foot bone. The Effector Location Space should be set to Bone Space and both the IKBone and Effector Target should be set to bone name.
Transform (Modify) Bone - Pelvis : The Bone to Modify should be set to the pelvis bone, the Translation Mode to Add to Existing and the Translation Space to Component Space
Transform (Modify) Bone - Feet : The Bone to Modify should be set to the left and right feet while the Rotation Mode should be set to Add to Existing and the Rotation Space to World Space.
9. Enjoy
image.png


Component Settings
Crouching
The ability to true crouch is very easy to set-up. You simply need to set bCanEverCrouch in the Details Panel of the component and your character will crouch over the network with a reduced capsule size. In order to change the size of the capsule, you will need to modify the CrouchedHalfHeight value in the CharacterMovementComponent under Character Movement (General Settings).

Sprinting
You can enable sprinting by setting bCanEverSprint to true in the Details Panel of the component. You can change the sprint speed by modifying the MaxSprintSpeed value.
You can also sprint while crouching by setting bCanSprintWhileCrouched to true and modifying the MaxSprintSpeedCrouched value.
Use the Sprint and StopSprinting functions to toggle sprinting.

Walking
You can enable sprinting by setting bCanEverWalk to true in the Details Panel of the component. You can change the sprint speed by modifying the WalkSpeed value.
You can also sprint while crouching by setting bCanWalkWhileCrouched to true and modifying the WalkSpeedCrouched value.
Use the Walk and StopWalking functions to toggle walking.

Sliding
There are two types of sliding implemented in the project: Root-motion Sliding and root-locked sliding. Each one comes with its own benefits. Both however implement True Sliding logic, which means that the capsule size of the character is reduced in order to be able to slide under obstacles.
In order to enable sliding, make sure bCanEverSlide is set to true in the Details Panel of the component.
Slide In Montage : Played in order to transition into the slide. Capsule size is normal at this stage.
Slide Main Montage : Played during the slide. In this step, the capsule size is reduced and you can rotate your character even if you are using root-motion sliding (in which case, EnableRootMotion should be set to true in the animation. Otherwise, set ForceRootLock to true.)
Slide Out Montage : Played afterwards to transition out of the sliding.

Root-motion Sliding
This type of sliding uses root-motion animations. Choose this mode by setting the bUseRootMotionForSliding value to true in the Details Panel of the component and make sure EnableRootMotion is set to true and ForceRootLock to false in the Slide Main animation.
This allows you to rotate your character during the sliding by setting the SlideRotationRate yaw value (yaw = 0 means no rotation allowed).

Interpolated/Root-locked Sliding
This type of sliding uses root-locked animations and interpolation. Choose this mode by setting the bUseRootMotionForSliding value to false in the Details Panel of the component and make sure both ForceRootLock and EnableRootMotion are set to true in the Slide Main animation.
This type of sliding interpolates the character’s position forward during the SlideMainMontage. You can set the speed and the distance of the slide by modifying the RootLockedSlideSpeed and RootLockedSlideDistance values.
This also allows you to rotate your character during the sliding by setting the SlideRotationRate yaw value (yaw = 0 means no rotation allowed).
The duration of the montage is the result of Time = Distance/Speed
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.