On my character (a ship) i have two colliders, one polygon collider 2D and one circle collider 2D.
The Polygon Collider 2D represents i’ts “body”, so when this collider collides with an obstacle (that uses Edge Colliders 2D) i want the ship to be destroyed.
The Circle Collider 2D is for detecting nearby coins.
My issue is that i don’t know how to remove the Circle Colliders ability to collide with the Edge Collider on the obstacle. Because now when the Circle Collider (that is only there to detect coins) collides with an obstacle it triggers the destroy method on the ship.
As you can see in left picture above, the ship gets destroyed when its Circle Collider touches the Edge Colliders, which is unwanted. Look at the right picture and you can see how i want the colliders to behave; the Circle Collider should ignore the edge colliders on the orange obstacle where as only the polygon collider triggers the destroy method.
Or more specifically, how can i modify this method (which is attached to the ship):
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag = "Obstacle")
{
Destroy (this.gameObject);
}
}
To only trigger when the ships polygon collider enters something, not when any of the ships colliders enters something.
I’d like to add that the Circle/Polygon collider has “is trigger”-option checked while the edge colliders do not have that.