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

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?

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.

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 :slight_smile:

So, for the guys like me who also stuck on implementing that feature :slight_smile:
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 Branch **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.

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?