Learn how to implement sprinting in Unreal Engine using Enhanced Input.
Firstly, we need to create a new Input Action
.
Content
>ThirdPerson
>Input
>Actions
folder and select Input
.Input Action
to create a new one.IA_Sprint
.Then, we need to select the Value type as Digital (bool)
.
After that, we need add IA_Sprint
to IMC_Default
and set the Key
as LeftShift
.
Now, to be able to use the IA_Sprint
, we need to prepare the BP_ThirdPersonCharacter
blueprint.
Firstly, we need to create a new two variable named WalkSpeed
and SprintSpeed
set it as Float
.
After that, we need to set the default value of WalkSpeed
and SprintSpeed
as 250
and 500
.
And then, we need to set Max Walk Speed
value in the Character Movement
component to 250
Now we can start to implement the sprinting logic.
Firstly, we need to create a new functions named SprintStart
and SprintStop
.
SprintStart
function will set the Max Walk Speed
value to SprintSpeed
.
SprintStop
function will set the Max Walk Speed
value to WalkSpeed
Everything is ready now, we can start to call IA_Sprint
in the BP_ThirdPersonCharacter
blueprint.