javascript for loop
for (var i; i < 10; i++) {
}
for loop
// Unity for loop coroutine (repeat something every x seconds for x time)
Coroutine doThisCoroutine; // (Create a coroutine for stopping)
int duration = 5 // (Duration, whatever you want it to be)
float waitTime = 1 // Wait time to iterate in seconds, usually 1
void Awake(){
DoThisCoroutine = StartCoroutine(DoThis()); // Start the coroutine
}
IEnumerator DoThis(){
while (enabled){ // While the behavior is enabled,
for (int x = 0; x < Duration; x++){ // From zero until 5 incrementing by 1...
print("Doing This!"); // Do whatever...
yield return new WaitForSeconds(waitTime) // Every second.
}
}
}
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