- Home /
A question related to the explosion after creation of debris
Hi mates!.
The fact is that I've got an object which disappears after clicking on it thanks to the first script. Then I apply another (the second) script which makes possible that a debris fall down from the disappearing position and I wanted to make, between these phases, an explosion or some particles effect.
So I created in the second script (which creates the debris) an instance of the particles effect at the same time (I suppose it) I create the debris.
But there's no effect. It doesn't work.
I receive a message through teh console like this: "UnassignedReferenceException: The variable explosion of 'newspam' has not been assigned. You probably need to assign the explosion variable of the newspam script in the inspector."
It must be something very simple.
Here's my code:
// Instantiate a rigidbody then set the velocity
var projectile : Rigidbody;
var explosion : Transform;
function Update () {
// Ctrl was pressed, launch a projectile
if (Input.GetButtonDown("Fire1")) {
// Instantiate the projectile at the position and rotation of this transform
var clone : Rigidbody;
var humo : Transform;
clone = Instantiate(projectile, transform.position, transform.rotation);
// Give the cloned object an initial velocity along the current
// object's Z axis
clone.velocity = transform.TransformDirection (Vector3.forward * 2);
humo = Instantiate(explosion, transform.position, transform.rotation);
}
}
Thanks in adavance.
Answer by syclamoth · Sep 18, 2011 at 05:20 AM
You need to drag and drop your explosion prefab onto the script component in the editor! It looks like it hasn't been assigned properly (Which, coincidentally, is exactly what that error message told you).
Thank you very much!. It works!! ;-) . I was wondering how to vote people who help me.
Your answer
![](https://koobas.hobune.stream/wayback/20220612214032im_/https://answers.unity.com/themes/thub/images/avi.jpg)