working on a 2d fighter type of game and its a charge mechanic I have, I set up the health good but how to I increment my energy when its charging? I've tried a do while but unity froze twice. any help?

increment the energy per second using Time.deltaTime when charging, like so…

[SerializeField] private float curEnergy;
[SerializeField] private float maxEnergy = 100;

void Update()
{
    if ( Input.GetKey( KeyCode.Space ) )
    {
        Charge();
    }
}

void Charge()
{
    if (curEnergy < maxEnergy )
    {
        curEnergy += Time.deltaTime;
    }
    else
    {
        curEnergy = maxEnergy;
    }
}

this is just an example…

Thanks alot! It worked like a charm. I completely forgot about the deltatime.