# Decreasing a value over time

**URL:** <https://forums.unrealengine.com/t/decreasing-a-value-over-time/309297>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE4, question, Blueprint\
**Created:** [March 5, 2015, 2:51am UTC](https://forums.unrealengine.com/t/decreasing-a-value-over-time/309297 "2015-03-05T02:51:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chasemcpherson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chasemcpherson](https://forums.unrealengine.com/u/Chasemcpherson)\
**Post date:** [March 5, 2015, 2:51am UTC](https://forums.unrealengine.com/t/decreasing-a-value-over-time/309297/1 "2015-03-05T02:51:39Z")

</div>

in my game i have a value, which is “thirst” and “hunger,” im trying to figure out a way to have them deplete over a set amount of time and have the time and value reset if the player consumes food or something. im new to UE4 and ive tried a few different ways to no avail.

---

<div class="post-metadata">

**Author:** ![MulleDK19](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MulleDK19](https://forums.unrealengine.com/u/MulleDK19)\
**Post date:** [March 5, 2015, 3:06am UTC](https://forums.unrealengine.com/t/decreasing-a-value-over-time/309297/2 "2015-03-05T03:06:44Z")

</div>

In the tick event subtract the delta time multiplied by the decrease per second.

newValue = oldValue - (deltaTime \* 5)

Where 5 is the amount to decrease per second.  
Clamp it to prevent it from going below zero.

---

<div class="post-metadata">

**Author:** ![Miroac](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Miroac](https://forums.unrealengine.com/u/Miroac)\
**Post date:** [March 5, 2015, 4:50pm UTC](https://forums.unrealengine.com/t/decreasing-a-value-over-time/309297/3 "2015-03-05T16:50:05Z")

</div>

Heya man, so Mulle had it down pack but I figured I’d throw together a graph to make it clear to you since you are new the UE4. Below is just an example of how you can make it work and a short explanation underneath.

 ![32483-reduce+thirst+over+time.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/b/60b142577c711703e4785bb8237226b69f9f3540.png)

The first part is how you would add to your thirst to boost it back up. Basically get your current **thirst** , add your **drinkie poos** , than clamp it cause you don’t want thirst going below zero or above your **thirst max** value, than set **thirst** to the new value and bingo, you just drunk something (life achievement awarded).

The second one is a little more complicated, using the Event Tick you can multiply the **Delta Seconds** with a **thirst rate** value. The reason I included a **thirst rate** value is because you can change this over time. Say you character is in the desert, **thirst rate** might be a value of 10.0, but while sitting and doing nothing in the desert you might change the value to 7.5.

Anyways, after getting your “rate” that you want the **thirst** to go going than you simply get the current **thirst** value, take away the rate of decay, and clamp it (again so it doesn’t go below zero), than finally set your **thirst** value again with the new value.

That should just about cover it.

---

<div class="post-metadata">

**Author:** ![MCaddict](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MCaddict](https://forums.unrealengine.com/u/MCaddict)\
**Post date:** [December 10, 2015, 3:32pm UTC](https://forums.unrealengine.com/t/decreasing-a-value-over-time/309297/4 "2015-12-10T15:32:44Z")

</div>

Here is the full on tutorial [[Part 21]-Hunger And Thirst System- How to make an advanced FPS game - Unreal Engine 4 - YouTube](https://www.youtube.com/watch?v=2h_mpHgbkcI)
