# Make stamina value only drain when sprint button is held and player is moving?

**URL:** <https://forums.unrealengine.com/t/make-stamina-value-only-drain-when-sprint-button-is-held-and-player-is-moving/323047>\
**Category:** Blueprint\
**Tags:** sprint, unreal-engine, issue, UE4, Blueprint, question\
**Created:** [June 25, 2015, 7:35pm UTC](https://forums.unrealengine.com/t/make-stamina-value-only-drain-when-sprint-button-is-held-and-player-is-moving/323047 "2015-06-25T19:35:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![VeXeD\_659](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VeXeD\_659](https://forums.unrealengine.com/u/VeXeD_659)\
**Post date:** [June 25, 2015, 7:35pm UTC](https://forums.unrealengine.com/t/make-stamina-value-only-drain-when-sprint-button-is-held-and-player-is-moving/323047/1 "2015-06-25T19:35:40Z")

</div>

I’m new to Unreal Engine 4.7.6 and I was following a tutorial online to set up a little basic game and was setting up the sprint mechanic. Well, there is a slight issue with standing in place and holding the run button where the stamina will then go down anyway without moving. I was hoping someone would be able to help me resolve this issue. I simply want the stamina value to drain when the player holds the sprint button and is moving, not when they hold the sprint button and stand still. I didn’t see this answered anywhere else except for multiplayer server game layouts, so I decided to ask. Any help is much appreciated. Thank you in advance.

 ![47895-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/0/9e0d02f2c1a2c06cf8adbae4e43980e3611cbe63.png)

 ![47898-capture2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/7/2/d72a952e31f303d4ecae6b4f5f186d7e15326127.png)

 ![47901-capture3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/2/a02e8bad6a7f4ef66091a7c0648b34abbfeaa90e.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6199feb8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6199feb8](https://forums.unrealengine.com/u/anonymous_user_6199feb8)\
**Post date:** [June 25, 2015, 8:44pm UTC](https://forums.unrealengine.com/t/make-stamina-value-only-drain-when-sprint-button-is-held-and-player-is-moving/323047/2 "2015-06-25T20:44:01Z")

</div>

I think you want to do something like check the charactermovementcomponent if accelration is not 0.

---

<div class="post-metadata">

**Author:** ![VeXeD\_659](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VeXeD\_659](https://forums.unrealengine.com/u/VeXeD_659)\
**Post date:** [June 26, 2015, 11:02am UTC](https://forums.unrealengine.com/t/make-stamina-value-only-drain-when-sprint-button-is-held-and-player-is-moving/323047/3 "2015-06-26T11:02:35Z")

</div>

What would I have to change to add this in?

---

<div class="post-metadata">

**Author:** ![Busymonkey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Busymonkey](https://forums.unrealengine.com/u/Busymonkey)\
**Post date:** [September 25, 2015, 10:13pm UTC](https://forums.unrealengine.com/t/make-stamina-value-only-drain-when-sprint-button-is-held-and-player-is-moving/323047/4 "2015-09-25T22:13:35Z")

</div>

I know this is 3 months old but I found threads with similar questions (I needed this as well) and found a solution through different threads.

You and I followed the same Sprint-tutorial and it’s pretty simple to implement the “drain-only-when-moving”-feature:  
First we check if the player is Sprinting (holding down Shift) - if it’s false, we’ll regain stamina. If it’s true we move on to check if the player is actually moving. We do this by getting the velocity of the player and checking if the velocity in any direction is equal 0, which means he’s standing still. If he’s not standing still (false) he’s Sprinting and we drain Stamina. If he’s holding down Shift but not moving (true) we should be regaining Stamina.

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/9/997c42d33d7a7d269da5a9b6ff3e08901c204d7f.png)

Credit to for suggesting “get velocity”.

([How to detect player movement? - Blueprint - Epic Developer Community Forums](https://answers.unrealengine.com/questions/32512/how-to-detect-player-movement.html))

---

<div class="post-metadata">

**Author:** ![Merlon](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/merlon/32/588488_2.png) [@Merlon](https://forums.unrealengine.com/u/Merlon)\
**Post date:** [October 30, 2022, 10:09pm UTC](https://forums.unrealengine.com/t/make-stamina-value-only-drain-when-sprint-button-is-held-and-player-is-moving/323047/5 "2022-10-30T22:09:05Z")

</div>

My method is in Spanish, sorry. But the method has worked perfectly for me, when I shift, the resistance no longer drops without moving, it only wears out when I move and shift.

 ![Captura de pantalla 2022-10-30 230147](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/e/4aec3c64964ac760253f5274385080e46fb4de66.png)

---

<div class="post-metadata">

**Author:** ![razmaz51](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/razmaz51/32/710746_2.png) [@razmaz51](https://forums.unrealengine.com/u/razmaz51)\
**Post date:** [April 2, 2025, 2:43am UTC](https://forums.unrealengine.com/t/make-stamina-value-only-drain-when-sprint-button-is-held-and-player-is-moving/323047/6 "2025-04-02T02:43:56Z")

</div>

Think maybe you could translate this?
