Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Why does this coroutine crash Unity?

$
0
0
This seems to crash my game every time it is run, can't figure out why. I've taken out the working code, but it's supposed to attack the player every x seconds. [enemStats holds the variables for that] private bool isAttackingPlayer; void Update () { if(!isAttackingPlayer) attackPlayer (); } private void attackPlayer(){ // enemy is in range [Attack!] StartCoroutine(attackingPlayer(enemStats.AttackSpeed)); // TODO start attack voice & animation } IEnumerator attackingPlayer(float waitTime){ isAttackingPlayer = true; // starting to attack yield return new WaitForSeconds (waitTime); // wait after cd // wait time ended if (playerStats.ShieldHP >= 0) // if there is a shield up playerStats.ShieldHP -= enemStats.Damage; else playerStats.PlayerHP -= enemStats.Damage; isAttackingPlayer = false; // no longer attacking }

Viewing all articles
Browse latest Browse all 2383

Trending Articles



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