ignore collision between this 3 way shot

Does anyone know how I would ignore collsions between this 3 way shooting effect? Each bullet has a rigidbody and box collider. I tried using the unity example:

Physics.IgnoreCollision(bullet.collider, collider);

But when I add this code into my bullet I get an error saying there is no Collider attached to the transform object the bullets shoot from and it no longer shoots 3 bulltes it just shoots one and I believe the code above is supposed to ignore the collision between the player and the bullet so how would I ignore collisions between all 3 bullets?

my bullet:

var bulletPrefab : Transform;
var bulletSpeed : int = 10000;

var bulletLeft = -10;
var bulletCenter = 0;
var bulletRight = 10;

function Update() 
{
    if(Input.GetMouseButtonDown(0)) 
    {
    	//bullet left
    	var bullet = Instantiate(bulletPrefab, transform.position, transform.rotation);
		bullet.transform.Rotate(0, bulletLeft, 0);
		bullet.rigidbody.AddForce(bullet.transform.forward * bulletSpeed);
        bullet.name = "iBullet";  
         	
    	//bullet straight
    	var bullet2 = Instantiate(bulletPrefab, transform.position, transform.rotation);
        bullet2.transform.Rotate(0, bulletCenter, 0);
        bullet2.rigidbody.AddForce(bullet2.transform.forward * bulletSpeed);
        bullet2.name = "iBullet";
        
        //bullet right
        var bullet3 = Instantiate(bulletPrefab, transform.position, transform.rotation);
        bullet3.transform.Rotate(0, bulletRight, 0);
        bullet3.rigidbody.AddForce(bullet3.transform.forward * bulletSpeed);
        bullet3.name = "iBullet";
        
    }
}

I guess after you finished all three instantiations, you could do:

Physics.IgnoreCollision(bullet.collider, bullet1.collider);
Physics.IgnoreCollision(bullet.collider, bullet2.collider);
Physics.IgnoreCollision(bullet1.collider, bullet2.collider);

Thanks legend411 passing the bullet1.collider into the second part did the trick plus I guess I was trying to do it after each instantiation and it was not recognizing them, when all I had to do was put them at the end, like you suggested :slight_smile: Thank You :smile: I had a brain fart lol

Wow I remember this post :slight_smile: seems like its been forever.

Instead of doing it like above which means adding every collision between these types of bullets especially if theres a lot… I found another way in case anyone else needs it (by tagging).

//THIS IS SO BULLETS NAMED "fireBullet" WONT COLLIDE WITH EACH OTHER
function Start () {
    ignoreCollision("fireBullet");
}

function ignoreCollision(tag : String) { 
    var objects = GameObject.FindGameObjectsWithTag(tag); 
    for (o in objects) { 
        if (o.GetComponent("Collider")  o != gameObject)
        Physics.IgnoreCollision(collider, o.collider); 
    } 
}