Ignore Collision Between Model and Player

Hello,

I'm working on a C4 script that allows the user to throw C4, if the C4 hits an object, then it will stick to it, else it will just fall to the ground. All that is working great, but I would like to Ignore all collision between C4 and the Player (and possibly anything with a tag).

There are two prefabs - one that is just a model that the player holds up with a script of:

var C4 : Rigidbody;

function Update()
{
    if (Input.GetKeyDown ("e"))
    {
        if (C4) {
        var Throw : Rigidbody = Instantiate(C4, transform.position, transform.rotation);
        }

    }
}

This Instantiates another Prefab with a rigidbody and a collider (this is the actual C4 that is placed on walls or one the floor etc... I would like to Ignore Collision on this prefab with Player and possibly anything with a tag of "test" - for now):

function Start ()
{

    rigidbody.AddRelativeForce (Vector3(1 * 100,-1 * 100,0));
    Physics.IgnoreCollision(rigidbody.collider, transform.root.collider);

}

function OnCollisionEnter(c : Collision) {

    var joint = gameObject.AddComponent(FixedJoint);
    joint.connectedBody = c.rigidbody;
}

Thanks,

Ollie

This could help it allows you to ignore collisions between two things but you might be able to use tags i don't know sorry Physics.IgnoreCollision: file:///Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/Physics.IgnoreCollision.html

Easiest is to put your C4 in a certain layer, like, say, named "C4" then put the player in another layer, like, "Player".

Then, open the physics settings (Edit > Project Settings > Physics) then in the Layer Collision Matrix, uncheck the association between the C4 layer and player layer. This will make your C4 pass through anything in the player layer.

Or add in the beginning of your OnCollisionEnter function:

if (c.gameObject.tag == "test")
   return

Although this won't stop your C4 from bouncing off a gameobject with that tag, but at least it won't stick to it.