mardi 23 novembre 2021

In Unity how do I stop perpetual math statements?

The question is simple but I can't for the life of me, figure it out.

My logic goes like this

// Static floats are StatBase.maxHealth = 0 and rStat.maxHealth = 70

class rStat : Monobehaviour
{

    
    public bool nomatter = false;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            nomatter = true;
        }


        if (nomatter == true)
        {
            healthcalc();
        }

        void healthcalc()
        {
         StatBase.maxHealth += rstat.maxHealth; // StatBase.maxHealth should = 70 but the 
                                                // number never stops adding

         nomatter = false;

        }
    }
}

Aucun commentaire:

Enregistrer un commentaire