2D Triggers and Collisions not working as expected.

I have a 2D planet defense game with asteroid prefabs I’d like to destroy when hit by a projectile.

The projectile has an EdgeCollider2D with “isTrigger” checked and the asteroids have an EdgeCollider2D and a RigidBody2D and is of Dynamic body type. I’ve attached pictures of the components of each as well as there collision / trigger scripts for reference.

Something interesting to note as well is that the asteroids do not collide with one another, however they do collider with the planet object which has only a CircleCollider2D.

I’ve tried adding a RigidBody2D to the projectile and using OnCollisionEnter2D, changing body type to kinematic, resetting z-positions, and double checking the correct layer names and script references!

Any thoughts are much appreciated!

Hey there,

As reference i can recommend you check out this link here which shows the interaction between triggers and colliders regarding OnTriggerEnter and OnCollisionEnter calls.

Upon reading this you might see that Triggers will not trigger any calls of OnCollisionEnter for that reason your projectiles do not work on your asteroids. As your projectiles are triggers you need an OnTriggerEnter here instead of OnCollisionEnter.

Thanks for the resource.

I managed to figure out that it is an issue with 2D Edge Colliders colliding with other 2D Edge Colliders.

I changed my projectile collider to a CapsuleCollider2D and now it triggers as expected.

That would also explain why the asteroids don’t collide with one another, but do collide with the planet.