Mesh Collider Problem

I had done my fps game for my college project in that the mesh collider is not working properly
collision is not happening between the bullet of the gun and thewalls

sometimes its colliding but sometimes its not colliding
i dont know the problem is with unity or in my script
this is the script i am using

function Update ()
{

Destroy(gameObject,2);
}
function OnCollisionStay(collision : Collision)
{
if (collision.rigidbody)
Destroy(gameObject);
}

and for the walls i gave mesh collider

okey must check out this first of all :

  • Make sure that one of the colliders has a non-kinematic rigidbody attached (the bullet logically should have a non-kinematic RigidBody)
  • Make sure that, if you re listening to the OnCollisionEnter event, that the Trigger property is not checked on the walls collider
  • Make sure that the collision layers match on your physics project configuration Here : Edit → Project Settings → Physics

1 -Walls are generally rectangular, so its better to use a box collider and to take care about well sizing it
2 - that script is attached to your bullet ? if so, are you sure about putting Destroy(gameObject,2); in the update function ? that means that your bullet will be destroyed after 2 seconds of its intanciation ! it might be destroyed before reaching the wall ! so no collision !
3 - Its better to use OnCollisionEnter than OnCollisionStay for bullet collision detection (logic implementation)

thanks sir i will try it and update my results

You should set the collision detection of the Bullet to Continuous and the Mesh collider must be static (without a Rigidbody). Have a look at the documentation for Rigidbodies: Unity - Manual: Rigidbody component reference