- Home /
Ignore collision with self?
Physics.IgnoreCollision(this.gameObject.rigidbody.collider, this.gameObject.rigidbody.collider);
Tried using that, but it doesn't like being used against itself..
So is there another way to ignore collision with self?
colliders dont collide with themselves, else you would get a OnTriggerStay call every frame, which you dont.
What is your intended behaviour and what is happening now that you are trying to fix.
Answer by alok-kr-029 · Feb 06, 2015 at 04:41 AM
The best way to do it is assign a specific layer to the game objects and use collision matrix table to ignore the collision between the layers edit->Project settings -> Physics- > collision Matrix
But it's with a single object, not two different ones.
So how would that work with a single object?
Add that game object to a new layer and change the collision settings in Physics setting. Objects in this layer will ignore collision.
It will work for any number of game object with same layer
For some reason the objects don't get any force when I try to disable the collision..
public float waitfordecollider = 0.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
waitfordecollider += Time.deltaTime;
if(waitfordecollider >= 0.1f)
{
collider.isTrigger =true;
waitfordecollider = 0.0f;
}
}
So I did something, I don't know what, but whenever I set my object to not collide with itself, it refuses to work with Rigidbody.Forcemode or anything like that.
So I switched to setting it to a trigger after .1 seconds, which has somewhat the same effect. Im just wondering if this can become an issue performance wise?