how can i make a int or double go down

hi! i am trying to make a script for players health stamina hunger and thirst. I am trying to make hunger and thirst decrease over time by 0.1 over a time of 3 minutes but i don’t know if there is a function to do so (also i did the stamina as a int beacuse i want to keep it round). I am new to programing so it might sound like a dumb question. Here’s the code i am working with.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player_Stats : MonoBehaviour {

public double Health;
public double Thirst;
public double Hunger;
public int Stamina;

// Use this for initialization
void Start () {
	Health = 100;
	Thirst = 100;
	Hunger = 100;
	Stamina = 100;
}

// Update is called once per frame
void Update () {
	
}

}

Hey there! We can do this by seeing how much time has elapsed with Time.deltaTime and then when it reaches 180 seconds, (3 minutes) decrease the players values.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player_Stats : MonoBehaviour
{

    public double Health;
    public double Thirst;
    public double Hunger;
    public int Stamina;

    public float healthDecreaseTimeSeconds = 180;
    private float deltaTimeThreshold;
    // Use this for initialization
    void Start()
    {
        Health = 100;
        Thirst = 100;
        Hunger = 100;
        Stamina = 100;
    }

    // Update is called once per frame
    void Update()
    {
        //Keep adding elapsed time
        deltaTimeThreshold += Time.deltaTime;

        //180 seconds in 3 minutes
        if (deltaTimeThreshold > healthDecreaseTimeSeconds)
        {
            Hunger -= 0.1f;
            Thirst -= 0.1f;
            deltaTimeThreshold = 0;
        }
    }

}

Let me know if this fixes it, if not reply to this, i’m happy to help! :smiley: