# How do I make a one Directional sprint?

**URL:** <https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682>\
**Category:** Blueprint\
**Tags:** sprint, unreal-engine, UE4, Blueprint, question, calls\
**Created:** [October 30, 2018, 3:36am UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682 "2018-10-30T03:36:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![OG\_FATFACE\_420](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OG\_FATFACE\_420](https://forums.unrealengine.com/u/OG_FATFACE_420)\
**Post date:** [October 30, 2018, 3:36am UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/1 "2018-10-30T03:36:22Z")

</div>

So I have set up a sprint feature where when I hold Left Shift, the speed changes to 600. However, I want to only make a one Directional sprint so when you are only holding the forward key (w)m you move forward, kind of like Call of Duty and Fortnite. I also want it to be able to sprint also when going left and forward. For example holding down w and a. Can someone send an example blueprint? Help is appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![PixelOmen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PixelOmen](https://forums.unrealengine.com/u/PixelOmen)\
**Post date:** [October 30, 2018, 5:05am UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/2 "2018-10-30T05:05:34Z")

</div>

You gotta stop duplicating this post my man.

---

<div class="post-metadata">

**Author:** ![poplockentaco](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@poplockentaco](https://forums.unrealengine.com/u/poplockentaco)\
**Post date:** [October 30, 2018, 5:33am UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/3 "2018-10-30T05:33:45Z")

</div>

Hi there,

One way you can do this is by checking if the controlled pawn/character’s current actor rotation is within a certain angle of the control rotation (aka, the rotation of where you’re looking) while the sprint button is held down. If the character is rotated too far compared to the control rotation then you can set the movement speed back to the non-sprinting speed, but when it is within the desired angle then you set it to the sprinting speed. You’d probably want to do this on tick so that it’s very responsive to your inputs. Also, you’d probably want to only use the Yaw value of each rotation when doing the comparison.

So it’d be something like this in blueprints:

 ![258070-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/e/33ed13874c1b61c39385ac8619f664982a060595.jpeg)

For reference, left shift is my “sprint” key in this case. **Sprint Speed** is 600.0, **Default Speed** is 400.0, and **Sprint Angle** is 45.0 degrees. The sprint angle is the most important variable in this case as it is what determines when you are sprinting “forward” or not.

Also, if you’d like to have a smoother interpolation between the default and sprint speeds you can add the following code to the function.

 ![258071-capture2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/b/53b51a634ff184c088a05161c41025e5b60062da.png)

Please note that _1)_ I’m using the “Delta Seconds” pin from the Event Tick function for the “Delta Time” of the FInterpTo functions, _2)_ that **Interp Speed** is a new variable I created that helps determine how slowly/quickly the interpolation occurs (I went with a value of 10.0 by default), and _3)_ this won’t smoothly speed up or slow down your character unless the sprint key is down so you may need to play around with it to get the desired outcome you want.

Hopefully this helps you achieve what you’re going for, or at the very least gets you thinking about how you can achieve it. With this setup though you should also be able to set up other “zones” where the speeds are different (maybe making the character move even slower than default while running backward?).

On a side note, a potentially better way to do this in C++ would be to create a custom character movement component and override the GetMaxSpeed function to include this calculation since it’s already being executed every tick. But don’t worry about that if you don’t know or have access to C++.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6981ce8c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6981ce8c](https://forums.unrealengine.com/u/anonymous_user_6981ce8c)\
**Post date:** [October 30, 2018, 9:58am UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/4 "2018-10-30T09:58:20Z")

</div>

Easier way is to just set a bool (e.g. “bForwardPressed”) true when the w key is pressed (can be done with event W key pressed). When sprint button is held, only set sprint true if bForwardPressed is true. If you need an example blueprint just comment below. Im more than happy to make one

---

<div class="post-metadata">

**Author:** ![OG\_FATFACE\_420](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OG\_FATFACE\_420](https://forums.unrealengine.com/u/OG_FATFACE_420)\
**Post date:** [October 30, 2018, 2:24pm UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/5 "2018-10-30T14:24:04Z")

</div>

Hello! Thank you for your help. If you can send me an example that would be nice!

---

<div class="post-metadata">

**Author:** ![OG\_FATFACE\_420](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OG\_FATFACE\_420](https://forums.unrealengine.com/u/OG_FATFACE_420)\
**Post date:** [October 30, 2018, 2:24pm UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/6 "2018-10-30T14:24:19Z")

</div>

Thanks for the help! I will try that later today.

---

<div class="post-metadata">

**Author:** ![OG\_FATFACE\_420](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OG\_FATFACE\_420](https://forums.unrealengine.com/u/OG_FATFACE_420)\
**Post date:** [November 1, 2018, 12:22am UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/7 "2018-11-01T00:22:04Z")

</div>

Hello! I out in your exact same code and it doesn’t seem to be working. I entered in the correct values. When I hold left shift, it sprints, then when I let go, it keeps sprinting. What should I do?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6981ce8c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6981ce8c](https://forums.unrealengine.com/u/anonymous_user_6981ce8c)\
**Post date:** [November 3, 2018, 5:53am UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/8 "2018-11-03T05:53:24Z")

</div>

Sorry for the wait, I’ll do that now. (I didn’t have access to my laptop for 4 days)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6981ce8c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6981ce8c](https://forums.unrealengine.com/u/anonymous_user_6981ce8c)\
**Post date:** [November 3, 2018, 8:22am UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/9 "2018-11-03T08:22:11Z")

</div>

![258403-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/8/0/88001371f2e04ffec4133a607064ddbe81589ee9.png)

Here it is. If it works, please accept the answer. If not, leave a comment to tell me what went wrong 🙂

---

<div class="post-metadata">

**Author:** ![OG\_FATFACE\_420](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OG\_FATFACE\_420](https://forums.unrealengine.com/u/OG_FATFACE_420)\
**Post date:** [November 7, 2018, 4:00pm UTC](https://forums.unrealengine.com/t/how-do-i-make-a-one-directional-sprint/436682/10 "2018-11-07T16:00:48Z")

</div>

Ok Thanks! It works now 🙂
