中学一年生です、
このエラーを教えて頂いたら助かります。
エラー内容
MissingReferenceException: The object of type 'EnamyManager' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
//
EnamyManager
private void Awake() { sphere = GameObject.Find("Sphere "); } //タップアクション //関数登録 Action tapAction; // クリックされたときに実行したい関数(外部から設定したい ) public new string name; public int hp; public int at; public GameObject hitEffect; //攻撃関数 public int Attack(PlaterManager player) { int damage = player.Damage(at); return damage; } // ダメージ受ける関数 public int Damage(int damage) { //プレハブの生成 親にするを設定する Instantiate(hitEffect, this.transform, false); //振動させる //0.3秒振動させる0.5f振動具合20振動させる transform.DOShakePosition(0.3f,0.5f , 20, 0, false, true); hp -= damage; Debug.Log("EnamyのHPは" + hp); if(hp <= 0) { hp = 0; } return damage; } //tapActionに関数を登録する関数 public void addEventListenerOnTap(Action action) { tapAction += action; } //クリックしたら public void OnTap() { Debug.Log("クリックされた"); tapAction(); }
Eanamy2
//タップアクション //関数登録 Action tapAction; // クリックされたときに実行したい関数(外部から設定したい ) public bool sphereBool = false; public new string name; public int hp; public int at; public GameObject hitEffect; //攻撃関数 public int Attack(PlaterManager player) { int damage = player.Damage(at); return damage; } // ダメージ受ける関数 public int Damage(int damage) { //プレハブの生成 親にするを設定する Instantiate(hitEffect, this.transform, false); //振動させる //0.3秒振動させる0.5f振動具合20振動させる transform.DOShakePosition(0.3f, 0.5f, 20, 0, false, true); hp -= damage; Debug.Log("EnamyのHPは" + hp); hp -= damage; Debug.Log("EnamyのHPは" + hp); if (hp <= 0) { hp = 0; } return damage; } //tapActionに関数を登録する関数 public void addEventListenerOnTap(Action action) { tapAction += action; } //クリックしたら public void OnTap2() { Debug.Log("クリックされた"); tapAction(); }
PlaterManager
//
//攻撃関数
public int Attack(EnamyManager enamy)
{
int damage = enamy.Damage(at); return damage; } public int Attack2(Eanamy2 eanamy2) { int damage = eanamy2.Damage2(at); return damage; } // ダメージ受ける関数 public int Damage(int damage) { hp -= damage; Debug.Log("PlayerのHPは" + hp); if (hp <= 0) { hp = 0; } return damage; } internal int Attack(Eanamy2 eanamy2) { throw new NotImplementedException(); }
}

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。