###前提・実現したいこと
5個のオブジェクトを全て違う位置に一気に表示し、そのオブジェクトが消えたらまた同じように表示するという処理をfor文で書いたのですが、2回目のfor文でフリーズしてしまいます
###発生している問題
1回目のfor文を終えたらIncorrectRandomFlgをfalseにし、オブジェクトを消す処理を終えてから、IncorrectRandomFlgをtrueにし再度for文を使おうと思っているのですが、2回目のfor文のときにunityがフリーズしてしまいます
###該当のソースコード
C#
1 if (IncorrectRandomFlg == true) 2 { 3 4 for (int a = 0; a < 5;) 5 { 6 7 IncorrectRandomNumver = Random.Range(0, IncorrectFigure.Length); 8 9 if (correctRandomNumber == IncorrectRandomNumver) 10 { 11 12 } 13 else if (correctRandomNumber != IncorrectRandomNumver) 14 { 15 randomLocation = Random.Range(0, 6); 16 if (randomLocation == 0 && upperFlg == false) 17 { 18 Instantiate(IncorrectFigure[IncorrectRandomNumver], new Vector2(0, 1), Quaternion.identity); 19 upperFlg = true; 20 a++; 21 } 22 else if (randomLocation == 1 && upperRightFlg == false) 23 { 24 Instantiate(IncorrectFigure[IncorrectRandomNumver], new Vector2(5, 1), Quaternion.identity); 25 upperRightFlg = true; 26 a++; 27 } 28 else if (randomLocation == 2 && upperLeftFlg == false) 29 { 30 Instantiate(IncorrectFigure[IncorrectRandomNumver], new Vector2(-5, 1), Quaternion.identity); 31 upperLeftFlg = true; 32 a++; 33 } 34 else if (randomLocation == 3 && lowerFlg == false) 35 { 36 Instantiate(IncorrectFigure[IncorrectRandomNumver], new Vector2(0, -2.5f), Quaternion.identity); 37 lowerFlg = true; 38 a++; 39 } 40 else if (randomLocation == 4 && lowerRightFlg == false) 41 { 42 Instantiate(IncorrectFigure[IncorrectRandomNumver], new Vector2(5, -2.5f), Quaternion.identity); 43 lowerRightFlg = true; 44 a++; 45 } 46 else if (randomLocation == 5 && lowerLeftFlg == false) 47 { 48 Instantiate(IncorrectFigure[IncorrectRandomNumver], new Vector2(-5, -2.5f), Quaternion.identity); 49 lowerLeftFlg = true; 50 a++; 51 } 52 53 } 54 } 55 56 IncorrectRandomFlg = false; 57 }
for文をコメントアウトし実行したところ、フリーズすることなく動いてくれたので、for文のところだけ抜粋しました
よろしくお願いします
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。