Destroy Projectile on collision

I am making a first person shooter where the player fires projectiles, How do i make the projectiles get destroyed as soon as they collide with somthing that is not an enemy or player. The way it is right now is that the bullets will collide with the ground and bounce off the ground/wall. How do i make the bullet get destroyed only when the bullet collides with the ground and walls?

So you want the projectile to destroy when it collides with anything BUT the enemy or player?

What you want to do is first check to see what the projectile collides with (make sure your projectile has a collider attached:

function OnCollisionEnter(collision : Collision){
   //next - check if we have collided with anything but player/enemy
   if(collision.gameObject.tag = "Player" || collision.gameObject.tag = "Enemy"){
      //do nothing - or apply damage maybe?

This has not been tested as I am not infront of Unity, but it should work.

Look at the scripting reference on how to use OnCollisionEnter function. you can use that on your bullet and add a Destroy(gameObject) inside.

This has been asked ad nauseam. Please Google for an answer.