- Home /
Instantiated Projectile IgnoreCollision Error
I have a basic turret that fires at an enemy. Everything is working fine, except that my Physics.IgnoreCollision() call is generating an error about my colliders not being active. the code looks like this:
function Fire()
{
Debug.Log("Firing turret...");
// instantiate our new bullet
var newProj = Instantiate(projectile, projSpawn.position, projSpawn.rotation);
// give it some forward velocity
newProj.velocity = projSpawn.TransformDirection(Vector3(0, 0, projSpeed));
Debug.Log("newProj collider: " + newProj.collider.enabled);
Debug.Log("transform root collider: " + transform.root.collider.enabled);
// let's have it ignore collisions with the turret
Physics.IgnoreCollision(newProj.collider, transform.root.collider);
}
The output is
newProj collider: True
transform root collider: True
So it seems that the colliders are both enabled, and so far I haven't been able to find anything significantly helpful on other questions and posts. Anyone else run into this problem and know a solution?
Comment
http://docs.unity3d.com/Documentation/ScriptReference/Physics.IgnoreCollision.html
Are you sure your code is asking for the right thing?