Wait for button click in recursive function
Is it possble to have a recursive function wait for the next iteration until you Click "Space" for example
kinda like this
void Start() { Recursive(parameter, parameter) }
void Recursive(parameter,parameter) { //some code
//wait for Key press to continue if(statement is true) { Recursive(parameter, parameter) } else { return }
Comment
Answer by xxmariofer · Apr 01, 2019 at 07:58 PM
i would use a corroutine for that
IEnumerator Recursive(param1, param2)//remember you need to call the recursive routine once
{
//your stuff
yield return new WaitUntil(Inpit.GetKeyDown(KeyCode.A));
StartCoroutine(Recursive(param1,param2));
}
Your answer
Follow this Question
Related Questions
Implementing Neural Network into Unity. Lots of calculations. 0 Answers
Noobie question: wait a random time 1 Answer
Wait inside a non void method 1 Answer
Co-routine a recursion help 0 Answers
Execute coroutine in Update() 8 Answers