Do-While loop

Hello
i have small problem with my do-while loop. I dont know what else i can use here

first of all i need this for my progress bar.
My script work fine until aeg = 1 and then freeze.
But when i use while(aeg <= 1);
then it start infinity loop starting with 1 and going forever.

if(Calc_Exp >= vaja_Exp){
				vaja_Exp = (vaja_Exp*2);
				level += 1;
				Level.text =("" + level);
				Calc_Exp -= vaja_Exp;
				do{
					aeg += Time.deltaTime;
					Debug.Log(aeg);
					Bar_Exp.transform.localScale = new Vector3(aeg, Bar_Exp.transform.localScale.y, Bar_Exp.transform.localScale.z);
				}while(aeg >= 1);

EDIT:
and it doing also outside do-while loop

when i put

do{
                     aeg += Time.deltaTime;
                     Debug.Log(aeg);
                     Bar_Exp.transform.localScale = new Vector3(aeg, Bar_Exp.transform.localScale.y, Bar_Exp.transform.localScale.z);
                 }while(aeg >= 1);
aeg = 0;

this always put aeg back to 0;

i try making filling status bar that what fill with time.

to be more specific

i make game where u get exp and when u die then pop up death menu and score will be converted to exp and with time exp bar will fill

Solution

I needed change good very hard :smiley: i did this with if statements here is my finnal working code, this work way it supposted to work.

	void Update () {
		if (activebool == true) {
			skoor = SchoreManager.scoreshare;
			//Cur_Exp += skoor / 100;
			aeg = Calc_Exp;
			activebool = false;
		}

		if (Cur_Exp >= vaja_Exp) {
			if(aeg < 1){
			aeg += Time.deltaTime;
			Bar_Exp.transform.localScale = new Vector3(aeg, Bar_Exp.transform.localScale.y, Bar_Exp.transform.localScale.z);
			}
			if(aeg >= 1){
				aeg = 0;
				Cur_Exp -= vaja_Exp;
				level += 1;
				Level.text =("" + level);
				vaja_Exp = (vaja_Exp * 2);
			}
		}
		if (Cur_Exp < vaja_Exp) {
			Calc_Exp = Cur_Exp/vaja_Exp;
			if(aeg < Calc_Exp){
				aeg += Time.deltaTime;
				float jooks = aeg;
				Bar_Exp.transform.localScale = new Vector3(jooks, Bar_Exp.transform.localScale.y, Bar_Exp.transform.localScale.z);}
		}
	}

But thanks for reply for those who did it.

Did you mean:

aeg -= Time.deltaTime;

? Otherwise, this is an infinite loop - aeg gets bigger and bigger forever.

for those who have same problem

	void Update () {
		if (activebool == true) {
			skoor = SchoreManager.scoreshare;
			//Cur_Exp += skoor / 100;
			aeg = Calc_Exp;
			activebool = false;
		}

		if (Cur_Exp >= vaja_Exp) {
			if(aeg < 1){
			aeg += Time.deltaTime;
			Bar_Exp.transform.localScale = new Vector3(aeg, Bar_Exp.transform.localScale.y, Bar_Exp.transform.localScale.z);
			}
			if(aeg >= 1){
				aeg = 0;
				Cur_Exp -= vaja_Exp;
				level += 1;
				Level.text =("" + level);
				vaja_Exp = (vaja_Exp * 2);
			}
		}
		if (Cur_Exp < vaja_Exp) {
			Calc_Exp = Cur_Exp/vaja_Exp;
			if(aeg < Calc_Exp){
				aeg += Time.deltaTime;
				float jooks = aeg;
				Bar_Exp.transform.localScale = new Vector3(jooks, Bar_Exp.transform.localScale.y, Bar_Exp.transform.localScale.z);}
		}
	}