Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

MissingReferenceException: The object of type 'CircleCollider2D' has been destroyed but you are still trying to access it.

$
0
0
I'm getting this error when I run my game: **MissingReferenceException: The object of type 'CircleCollider2D' 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.** When I run my game, everything works perfectly fine and I'm not sure where this error is coming from.. I was hoping one of you amazing people could take a look and shed some light! Here is the code: public class EnemyAttackGen1 : MonoBehaviour { public GameObject attackEffect; public int damageAmmount = 20; IEnumerator OnTriggerEnter2D(Collider2D enemy) { if (enemy.tag == "Enemy") { yield return new WaitForSeconds(0.5f); if (GetComponent().open) { GetComponent().currentHealth -= damageAmmount; } Instantiate (attackEffect, enemy.gameObject.transform.position, enemy.gameObject.transform.rotation); Destroy(enemy.gameObject); } } } Let me know if you need more information! Thank you in advance

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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