I need to repeat one line of code x number of times determined by an int variable. This code is in the Start function. How do I go about achieving this?
use for, while or if
f.e.
int i=0;
int amount = 0;
while (i < amount){
//your code here
i++;
}
or
for (int i = 0; i < amount; i++) {
//your code here
}
You can use “for” loop or “while” this is example :
int x; //your int variable
void Start () {
for(int i = 0; i < x; i++){
//your line/lines of code
}
}
You can use a for loop.