Question by
Miyahonmoto · Sep 05, 2020 at 02:34 PM ·
instantiatereferencegameobjects
My programming says "The referenced script on this Behaviour (Game Object 'explosion_asteroid') is missing!" although my Scripts works fine.
I made a shooting Game from Official Unity Video(https://www.youtube.com/watch?v=2KRLVRPdoKQ) and When I made a script that explode asteroids when it hits to the laser and spaceship if spaceship collide asteroids, but when I run the game there are errors of "The referenced script (Unknown) on this Behaviour is missing!" "The referenced script on this Behaviour (Game Object 'explosion_asteroid') is missing!" "The referenced script on this Behaviour (Game Object 'explosion_asteroid') is missing!" I already research this errors on different websites but I didn't understand well to solve this problem. I want to know the way to solve this problem of reference and instance.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyByContacts : MonoBehaviour
{
public GameObject explosion;
public GameObject PlayerExplosion;
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Boundary")
{
return;
}
Instantiate(explosion, transform.position, transform.rotation);
if (other.tag == "Player")
{
Instantiate(PlayerExplosion, other.transform.position, other.transform.rotation);
}
Destroy(other.gameObject);
Destroy(gameObject);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613011256im_/https://answers.unity.com/themes/thub/images/avi.jpg)