system
1
I need help with my explosion script
var explosion : Transform;
function OnCollisionEnter(collision : Collision) {
Instantiate(explosion,GameObject.Find("Bullet") . transform.position, Quaternion.identity);
Destroy (GameObject);
}
im trying to attach it to my Bullet
if the script is attached to the bullet you don’t need to use GameObject.Find, just use transform.position, all the rest is already ok
To attach the explosion to your bullet, you could use the following:
var explosion : Transform;
function OnCollisionEnter(collision : Collision) {
var explosionObj = Instantiate(
explosion,
GameObject.Find("Bullet").transform.position,
Quaternion.identity
);
explosionObj.transform.parent = GameObject.Find("Bullet");
Destroy (GameObject);
}
have you assigned the explosion to the variable through the inspector?