- Home /
Question by
Mikaelgameryolo1 · Nov 24, 2019 at 06:19 PM ·
c#for-loopsimple
"for "Loop problem
I want this "for" loop to do the following: a)Check between 1 and RelativePosition(aka, 4) b)See if the current item is available c)If it is, it should print Yeet d)If it isn't, the loop should skip this item and move on
But for some reason, it doesnt do that, and i dont understand why. Can anyone help?
Code:
int RelativePosition = selected.currentSquare.idR;// aka, 4
for (int i = 1; i < RelativePosition; i++)
{
if (toBeFiltered[i].available)
Debug.Log("Yeet");
else
break;
}
Comment
Best Answer
Answer by zactanpeterson · Nov 24, 2019 at 06:22 PM
Using "break" exits the loop, you could use "continue", but there's no point, just take out the else statement
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to find the minimum number in a float array C# 1 Answer
Simple pendulum swinging script trouble 2 Answers
Text isn't showing up on button 0 Answers