Problem with Do While loop crashing unity

Thanks everyone for helping.

What i did was get rid of the Do While loop and make it a if else in the update.

void Update () 
	{
		if (Input.GetKeyDown (KeyCode.Space))
			startEndTurn = true;
		if (startEndTurn == true)
			CheckEndMov ();
	}
void CheckEndMov ()
	{
		GameObject[] units;
		units = GameObject.FindGameObjectsWithTag (unitTag);

		if (allMovComp == true) {
			Attack ();
			startEndTurn = false;
			allMovComp = false;
		} else {
			allMovComp = true;
			foreach (GameObject unit in units) 
			{
				if (unit.GetComponent <Move> ().notMovin == false)
					allMovComp = false;
			}
		}
	}

You should put this in a coroutine.

Clearly it’s running infinitely… with at least one object’s novMov being false, which can’t ever change until this loop exits and allows the objects to update.

There are no needs of doing that in loops my friend! And think about it, you have a foreach loop in a do loop! Really bad idea! There are tons of ways to have the same result without loops :slight_smile:

Show me your script and I’ll adapt it for you.