Quantcast
Channel: Questions in topic: "breaking"
Viewing all articles
Browse latest Browse all 16

Breaking out of a function from an if statement inside..... Noob

$
0
0
Hi, OK, what I'm trying to do, is this.... private bool moveDown = false; private int state = 0; void Update() { if( moveDown ) { DoMyFunction(); return; } if( somethingElse ) { moveDown = true; } } private void DoMyFunction() { if( state == 0 ) { //vector lerp blah blah bla.. state = 1; } if( state == 1 ) { //vector lerp blah blah bla.. state = 2; moveDown = false; return; //THIS IS WHERE I WANT TO JUMP OUT OF THE FUNCTION AND BACK TO UPDATE UNTIL moveDOWN IS TRUE AGAIN, AT WHICH POINT WE'LL START AT THE IF(STATE==2) } if( state == 2 ) { //vector lerp blah blah bla.. state = 0; moveDown = false; return; //BREAK OUT OF FUNCTION AGAIN UNTIL moveDOWN IS TRUE AGAIN AND START AT THE BEGINNING } I thought that I would be able to break out of the function with return, at which point the update would recognize moveDown as false and discontinue calling DoMyFunction until moveDown was true again. Unfortunately DoMyFunction continues to run after moveDown is declared as false..... I'm super confused!! Can anyone help with this? Much appreciated!!

Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>