現在Unityでシューティングを作っていて、ボスを倒したらクリア画面になるようにしたいです。
ビルドする前はそれがうまくいっているのですが、PCでプレイするようにビルドするとクリアのコルーチンが起動しません…。
他のコルーチンは問題なく動いています。
因みにWindows7です。
以下コードです
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class BossScript : MonoBehaviour
{
public int BossHP;
private Animator anim;
public GameObject Hit;
public GameObject Explosion;
public Transform bullet;
public Transform Bosspos;
public GameObject boss;
// Use this for initialization void Start() { anim = GetComponent<Animator>(); } // Update is called once per frame void Update() { if (BossHP < 1) { StartCoroutine("Clear"); } } void OnTriggerEnter(Collider collision) { if (collision.gameObject.tag == "Ball") { print(BossHP); StartCoroutine("BossDamage"); } } IEnumerator BossDamage() { BossHP -= 1; anim.SetBool("Damage", true); GameObject Hits = GameObject.Instantiate(Hit) as GameObject; Hits.transform.position = bullet.position; Destroy(Hits.gameObject, 2); yield return new WaitForSeconds(0.3f); anim.SetBool("Damage", false); } IEnumerator Clear()//ここのコルーチンが動きません… { GameObject Explosions = GameObject.Instantiate(Explosion) as GameObject; Explosions.transform.position = Bosspos.position; yield return new WaitForSeconds(5f); SceneManager.LoadScene("Clear"); Destroy(boss.gameObject); }
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。