我遇到以下问题:下面的//takedamage
代码正常运行,但当我添加//respawn
代码时,它停止了工作,我没有收到任何错误。游戏的其余部分似乎运行良好,只是//takedamage
代码无法正常工作。
//takedamage
public override IEnumerator TakeDamage (){
health -= 10;
if (!IsDead) {
MyAnimator.SetTrigger ("damage");
} else {
MyAnimator.SetLayerWeight (1, 0);
MyAnimator.SetTrigger ("die");
}
yield return null;
}
//respawn
void OnTriggerEnter2D(Collider2D other){
if(other.tag == "FallDetector"){
transform.position = respawnPoint;
}
if (other.tag == "Checkpoint") {
respawnPoint = other.transform.position;
}
}
我无法弄清问题是什么。我是C#
的新手,所以欢迎任何帮助。