- Home /
Stopping One Function From Another
Sup. When my character gets hit by an enemy attack, he successfully does his hit animation and loses damage. What I need is a solution to make it so that if he gets hit while he's attacking, the attack function will stop. The reason this is difficult is because I need the attack function to stop from the being hit function, making return; unusable. Here's the scripts. Note: Super big attack script because it's a portion of a combo.
function BeingHit (){ isAttacking = false; comboable = false; animation.CrossFade("getHit",0.03); yield WaitForSeconds(.5); beingHit = false; }
function QuickCombo1() {
isAttacking = true; if(isAttacking == true){ animation.CrossFade("qc1"); yield WaitForSeconds(.5); hitTimeSmall = true; attackMove = true; yield WaitForSeconds(.2); attackMove = false; yield WaitForSeconds(.5); hitTimeSmall = false; comboable = true; yield WaitForSeconds(0.3); if(inCombo == false){ comboable = false; isWalking = true; isMoveable = true; isAttacking = false; } } }
Answer by by0log1c · Mar 09, 2011 at 04:53 AM
How about trading the if(){} for a while(){} ?
Making the condition false will stop the script at anytime, theoretically.
yes I agree, and you would also need to add an isAttacking = false at the end of the loop so the loop ter$$anonymous$$ates even if the character is not attacked
Your answer
![](https://koobas.hobune.stream/wayback/20220613111951im_/https://answers.unity.com/themes/thub/images/avi.jpg)