bullet explode on impact

how do i set up an explode on impact with anygame object including terrain.
i have a tank with a bullet prefab attached to the main gun.
The gun works fine and shoots well i just want the (bullet or shell)
to explode when it hits anything.

thank you for reading this

wayne

Add a script to the bullet’s prefab, and write that inside :

function OnCollisionEnter( var col : Collision )
{
    if( col.transform.tag != theTankTag )
        instantiate( explosion );
}

Replace theTankTag by the tag of the tank, and add the var explosion with a prefab. Now, be aware that bullet collision might be tricky as they usually are quite fast, and so can easiliy miss a collision. Consider using raycasts if you have problems.

Add a rigidbody to the bullet and disable the rigidbody gravity.