# losing stamina while holding shift and not moving

**URL:** <https://forums.unrealengine.com/t/losing-stamina-while-holding-shift-and-not-moving/1156620>\
**Category:** Blueprint\
**Tags:** unreal-engine, question, Blueprint\
**Created:** [May 6, 2023, 3:11pm UTC](https://forums.unrealengine.com/t/losing-stamina-while-holding-shift-and-not-moving/1156620 "2023-05-06T15:11:32Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![L1z4rD89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/l1z4rd89/32/1194537_2.png) [@L1z4rD89](https://forums.unrealengine.com/u/L1z4rD89)\
**Post date:** [May 8, 2023, 6:51am UTC](https://forums.unrealengine.com/t/losing-stamina-while-holding-shift-and-not-moving/1156620/6 "2023-05-08T06:51:16Z")

</div>

Hey @adnemannen

here is a small example:

Set the **MaxWalkSpeed** for the character in the beginning

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/2/1/42100d7265e8f1b074cb0a828948515d746d715e.png)

Set **IsSprinting** , then set the corresponding **MaxWalkSpeed** , clear a timer if there is one via the **TimerHandle** and then set a timer for consuming the stamina or regenerating stamina. These timers use a different time for looping, **ConsumeTime** = fast 0,01, **RegenTime** = slow 0,1.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/8/b/08b032edc648ce88b212f27c750820d11c47092c.png)

Simple move input

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/6/c268aeb6006e41f9644f392c2d94cbe8e4d45f14.png)

The looping event called **Stamina**. Yes you can use an event for a **SetTimerByFunctionName**. First, we check if the character is sprinting AND is moving.  
If the character does both, we check if the **CurrentStamina** is above 0 and then decrease it.  
If the character does neither, we check if the **CurrentStamina** is less than the **MaxStamina** and then increase it.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/3/b1353b45ee10546c3b618a39a20a6e358424b8c4.png)

Starting values =\>  
CurrentStamina = 100  
MaxStamina = 100  
IsSprinting = False  
ConsumeTime = 0,01  
RegenTime = 0,1  
WalkSpeed = 300  
SprintingSpeed = 600

In your case it would look like this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/b/efb3dd31226cd98b200b594d02f8930eb49a58f2.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/f/56f5b35c8d10f9aef44c454a875ade53b2559485.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/8/0/780eae8ecb3d1bd3f2e048fd64c7c4d2911a47ff.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/3/5a3121a03ac4839403e45b7b3f533adf45f752bd.png)

Keep in mind that both ways are currently only changing the stamina and do not stop the character if the stamina is 0.

Here is another example:

> [@I cant get my progress bar to work as i want (in blueprints)](https://forums.unrealengine.com/t/i-cant-get-my-progress-bar-to-work-as-i-want-in-blueprints/632850/4):
>
> I created a 3d person template. Inside the ThirdPersonCharacter I added these values: Stamina: Float MaxStamina: Float StaminaDepleted: Boolean WidgetRef: UserWidgetObjectReference EventBeginPlay: Sprint: Refuel: And inside the widget: [image] Edit: [StaminaPoints.zip - Google Drive](https://drive.google.com/file/d/1eZj8i3ckdiZNuDEpRmIJRTx8NS29xpd3/view?usp=sharing)

---

_[View the full topic](https://forums.unrealengine.com/t/losing-stamina-while-holding-shift-and-not-moving/1156620)._
