# Implementing speed decrease if character strafe left/right/backwards. How you do this?

**URL:** <https://forums.unrealengine.com/t/implementing-speed-decrease-if-character-strafe-left-right-backwards-how-you-do-this/103318>\
**Category:** Character & Animation\
**Tags:** unreal-engine\
**Created:** [November 30, 2017, 2:38pm UTC](https://forums.unrealengine.com/t/implementing-speed-decrease-if-character-strafe-left-right-backwards-how-you-do-this/103318 "2017-11-30T14:38:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander.L](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexander.L](https://forums.unrealengine.com/u/Alexander.L)\
**Post date:** [November 30, 2017, 2:38pm UTC](https://forums.unrealengine.com/t/implementing-speed-decrease-if-character-strafe-left-right-backwards-how-you-do-this/103318/1 "2017-11-30T14:38:25Z")

</div>

Hi guys

As we’re all know, in most (probably all) games where we can sprint, we can’t do this if move backward/left or right.  
During planning to implementing that sort of typical FPS/TPS games behavior to character movement I wondered which option would be the most successful. How you guys doing that?

Thats a really simple character movement behavior but looks like in will be not so simple in BP.  
The first thing that came to mind: checking **is input key down** , checking some combinations like"Shift" + W and A/D - thrue so we can sprint, and so on. But i believe (almost 100% sure) its really not best or even good way to do this.

Im really not sure but is there any option of something like “get player movement local vector” that we able us to know if our player trying strafe or move backward/left/right so we can decrease his speed with some value suitable for conditions (walking/crouching).

Any opinions or advice?

---

<div class="post-metadata">

**Author:** ![VaSSiLi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VaSSiLi](https://forums.unrealengine.com/u/VaSSiLi)\
**Post date:** [December 1, 2017, 12:50am UTC](https://forums.unrealengine.com/t/implementing-speed-decrease-if-character-strafe-left-right-backwards-how-you-do-this/103318/2 "2017-12-01T00:50:49Z")

</div>

Here’s one potential solution: InputAxisMoveForward and InputAxisMoveRight both contain float data that will equal 1.0 when the key is pressed down (Or when an analog controller has hit its max threshold). You could modify this input axis value to be a fraction of itself if the value is negative.

See attached image.This might not be the perfect solution, but it should work for most cases, particularly FPS.

---

<div class="post-metadata">

**Author:** ![Alexander.L](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexander.L](https://forums.unrealengine.com/u/Alexander.L)\
**Post date:** [December 1, 2017, 7:52pm UTC](https://forums.unrealengine.com/t/implementing-speed-decrease-if-character-strafe-left-right-backwards-how-you-do-this/103318/3 "2017-12-01T19:52:25Z")

</div>

Many thanks for advice VaSSiLi!  
God… i dont even think that all that fancy calculations like “\>=” can be done with input. Feel myself pretty stupid :)) Anyway, now character work’s as it should and now i know a little more about coding in BP 🙂

---

<div class="post-metadata">

**Author:** ![Alexander.L](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexander.L](https://forums.unrealengine.com/u/Alexander.L)\
**Post date:** [December 1, 2017, 8:36pm UTC](https://forums.unrealengine.com/t/implementing-speed-decrease-if-character-strafe-left-right-backwards-how-you-do-this/103318/4 "2017-12-01T20:36:33Z")

</div>

So, for the guys like me who also stuck on implementing that feature 🙂  
Here’s the picture. Why i added secon **Branch** :  
On mark “A” we are checking if our float on \*\*Axis Input \*\*for moving forward/backward are bigger or equal 0? If we pressed **“W”** they are bigger that 0 (they are 1) and in first **Branch** we have = \*\*thrue \*\*then we set out variable **Final speed** \*\*= 1 \*\*and character move forward with some speed what you set in other part of you blueprint or in characher default values.  
When we pressed **“S”** for moving backwards our float in \*\*Axis Input **change value to -1 an in first B** ranch \*\*we have = \*\*false \*\*when we go to second \*\*Branch \*\*which are check if our character sprint? If = \*\*thrue \*\*- we set \*\*Final Speed \*\*with \*\*Axis Value \*\*input, so -1 \* 0.25 = - **0.25** (in my case that value are the best) and character move backward with some decreased or default “walk speed”.  
But if second \*\*Branch \*\*(mark “B”)have = \*\*false \*\*cause we’re not sprinting, when we again set \*\*Final speed \*\*with default \*\*Axis Input \*\*value which is **= 1**.

Why we need that? Because we only need to prevent character to move backward with high sprinting speed, but we also want to be able to “walk” or “crouch” backward with some default speed’s for that actions.

---

<div class="post-metadata">

**Author:** ![The\_Stream\_Box](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@The\_Stream\_Box](https://forums.unrealengine.com/u/The_Stream_Box)\
**Post date:** [December 17, 2020, 10:32am UTC](https://forums.unrealengine.com/t/implementing-speed-decrease-if-character-strafe-left-right-backwards-how-you-do-this/103318/5 "2020-12-17T10:32:15Z")

</div>

Hi,

Sorry for digging up this up as it’s a few years old. I’m struggling with implementing a strafe speed in a shooter and this feels like it could work. Is this methodology computationally difficult though? Is this significantly more computationally difficult than using a method of setting the move speed variable each time say the sprint button is pressed?
