- Home /
Object reference not set to an instance of an object.
Hello everyone. I started using Unity today and I made a character that can shoot. Now I want my "Bullets" to disappear with an explosion when coliding with something. The explosion occurs, however the bullet does not disappear. This is my Destroy object code:
var explosion : GameObject;
function Update(){
}
function OnCollisionEnter(collision : Collision){
var explosionClone=Instantiate(explosion, transform.position,transform.rotation);
explosionClone.GetComponent("Detonator").Explode();
Destroy(gameObject);
}
Does anyone know what's causing the problem? Any help is highly appreciated. Cheers, Andrew.
Problem Fixed. Restarting Unity fixes it.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613094120im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Object Refererence not set yada yada... 2 Answers
NullReferenceException was thrown. Object reference not set to an instance of an object. 1 Answer
NullReferenceException:"Object reference not set to an instance object" 1 Answer
Object reference not working 0 Answers
(Javascript) Object reference not set to an instance of an object 1 Answer