question

brendan avatar image
brendan asked

Implementing resource timers (hunger, thirst, etc.)

Question from a developer:

How would I go about implementing resource timers for things like a hunger or thirst bar? Or for a value that decreases over time?

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The simplest way of doing this would be by using a regenerating currency. Just consider that the max recharge level is your "empty". So, using Fallout as the example, your hunger and thirst raise as time passes. You could do exactly that by setting up a regenerating virtual currency which increases at the rate you want hunger and thirst to increase.

The same is true for a value that decreases over time, though you need to think of it the other way around when setting it up (since regenerating currencies increase over time). In other words, set up a maximum recharge value based upon the total amount that the player can have, but then start the player at zero and let the VC charge up. When you show the player their value, you would then reverse it by showing the current player value as the max minus the current value - and so, decreasing over time until it hits zero.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.