for loop unity
for (int i = 0; i < 50; i++)
{
//Do something 50 times
}
for loop unity
for (int i = 0; i < 50; i++)
{
//Do something 50 times
}
unity while loop
//you can do:
int count = 0;
while(count < 10)
{
print("This text will run 10 times!!!, this is: " + count);
}
//for infinite loop (use update instead)
while(true)
{
print("Spam");
}
how to make a loop in unity
public bool one = true;
public bool two = false;
public float delay = 2f;
void Update()
{
if(one == true) // the delay at the top is the amount
{ // of seconds until you call the Function
Invoke("One", delay); // again so if the delay were 3f it
one = false; // whould be three seconds until you call
} // the Function again
if(two == true)
{
Invoke("Two", delay);
two = false;
}
}
void One()
{
two = true; // where it says "FunctionName" is the name
FunctionName(); // of the function you want to be called
} // for example if your function is called
void Two() // "void Move()" then it whould be "Move"
{ // instead
one = true;
FunctionName();
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us