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