- Home /
what does "for" mean
example for (var i = 0; i < Input.touchCount; ++i) { if (Input.GetTouch(i).phase == TouchPhase.Began) { Application.LoadLevel ("1");
what does for mean is it diffrent from if and where is it used
Answer by Kag359six · Mar 29, 2012 at 08:26 PM
a for loop is a type of loop. that standard for loop sets variable i to 0, and its says as long as i is less than the user touch count, then add one to i. so its going to add 1 until i is equal to Input.touchCount.
Answer by perchik · Mar 30, 2012 at 04:58 PM
'For' is a type of loop. It allows you do one operation for some number of times. An example for loop looks like this :
for(int i=0; i<10; i++){
print i;
}
First this sets i=0. Then it checks to see if i is less than 10 (i<10). If it is, it goes into the loop and prints out i. Then it increments i, by adding 1 to it ( i++) and checks to see if its less than 10 again. This keeps repeating until i is no longer less than 10.
Your answer
Follow this Question
Related Questions
Wtf is a prefab? 2 Answers
What is network group number in network.Instantiate? 0 Answers
Whats wrong about what i am doing? 1 Answer
How to create a parallel for in Unity 4 Answers
Read Array Inside Array 0 Answers