Can Some One Say Why Unity Crashes When i Run This Script

public void Right()
{
IsHoldingRight = true;
if (Mg.IsRed)
{
while (IsHoldingRight == true)
{
this.gameObject.transform.Translate(MovementSpeed * 5f * Time.deltaTime, 0f, 0f);
Debug.Log(“Moved Red To Right Holding”);
}
}
}

Please use code-tags when posting code. It’s right there in the edit toolbar.

There’s nothing there that would directly cause a crash. It wuold be helpful if you actually posted the “crash” and exactly what you mean by crash i.e. Unity just quits, you get an exception in the console etc.

Just looking at it quickly it looks like an infinite while loop, how is it supposed to break out of it?

1 Like

I must’ve been tired, didn’t see it, well spotted.