Projectile Collision help

Hey, I am playing around with a projectile here and this function wont work (the particle wont instantiate). Thank you in advance:

//Variables (START)_________
//The particles that will Instantiate on hit
 
var mudParticle : GameObject;
 
//Variables (END)___________

function OnCollisionEnter (hit : Collision)
{
if(hit.transform.tag == "floorMud")
    {
    Instantiate(mudParticle, transform.position, transform.rotation);
    transform.renderer.enabled = false;
    gameObject.GetComponent(SphereCollider).enabled = false;
    }
}

Try debugging you code with MonoDevelop. You can add a breakpoint on line with the if (…) statement.

You can then check if the tag of the hit object is “floorMud” and verify that “mudParticle” isn’t a null reference.

http://docs.unity3d.com/Documentation/Manual/HOWTO-MonoDevelop.html

If it’s a case of the bullet only being detected when it is travelling slow, but you want your bullet to move fast, you may want to do a raycast from the bullet with a distance of one. I had a similar problem on my first ever demo game and my bullets just passed through objects.

A sample code would be

var bullet : Transform;
var speed : float = 50.0//Or whatever you want it to be

Function Update ()

{
var hit = RaycastHit;

transform.Translate (0, 0, speed * Time.deltatime);

if (Physics.Raycast (transform.position, transform.forward, hit, 1)
{
if (hit.transform.tag == “Something”)//replace with tag of object you want to destroy
{
Destroy (gameObject);
}
}
}

This will mean that when the Raycast hits something with the tag of your object, it will react as soon as it hits and more accurately then the bog-standard colliders that Unity provides.