Spawn rigidbody on collision

Hi everyone. I’m working on a game where you can blow up basically anything, similar to Red Faction. I made a script that turns a gameObject into a rigidbody when it is collided with another game object. Everything about the script works, except for one thing. Right as the game starts, the gameobject is destroyed and turned into the rigidbody, even though it is not touching anything.

Can someone help me out with this?

var deadreplacement : Rigidbody;
var explosion : Transform;

function Update()
	deadreplacement = Instantiate(deadreplacement, transform.position, transform.rotation);

function OnCollisionEnter(collision : Collision) {
	Destroy (gameObject);
    Instantiate(explosion, transform.position, Quaternion.identity);

(Please be aware that I am really new to scripting, and not that good at it)

Thanks in advance :smiley:

I just realized the gameobject is being destroyed because the rigidbody is colliding with it -_-

Your object is probably colliding with the ground or something similar. Have you checked the layer it’s in?