Decreasing a value over time

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.

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.

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.

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.

Here is the full on tutorial [Part 21]-Hunger And Thirst System- How to make an advanced FPS game - Unreal Engine 4 - YouTube