- Home /
IgnoreCollisions Exception
I am using this code to force objects to ignore collisions on an array of other objects:
ballList = GameObject.FindGameObjectsWithTag("ball");
for (ball in ballList)
{
Physics.IgnoreCollision(ball.collider, collider);
}
When I run the game I get this exception:
Scene::setShapePairFlags: The two shape references must not reference the same shape. UnityEngine.Physics:IgnoreCollision(Collider, Collider, Boolean) UnityEngine.Physics:IgnoreCollision(Collider, Collider, Boolean) UnityEngine.Physics:IgnoreCollision(Collider, Collider)
What does this mean and how can it be fixed?
Answer by Eric5h5 · Jul 10, 2010 at 01:38 AM
Change
Physics.IgnoreCollision(ball.collider, collider);
to
if (ball.collider != collider) {
Physics.IgnoreCollision(ball.collider, collider);
}
It amazes me that you can understand what's going on with his script even though he posted so little information. Probably one reason you're the one with 13k rep points around here. :P
Answer by qJake · Jul 10, 2010 at 01:32 AM
Your ball
is the same game object that the script is on, so ball.collider
and collider
are exactly the same component. I don't know how to fix it, but you can't give IgnoreCollisions()
the same reference twice.
Or you could have just read the error message, which explains exactly what I just said:
The two shape references must not reference the same shape.