# How do I ensure consistent behaviour when using Unity's Collider2Ds for triggers and collisions?

I am experiencing inconsistent behavior using Unity's 2D Physics engine and their Collider2Ds to detect collisions and triggers on my projectiles. I will classify it into two problems. The first is that occasionally the projectile will pass through walls/objects it should collide with. The second is that occasionally the projectile will pass through enemies that it should hit without triggering. I will try to elaborate in detail below.

A projectile is organized into a container Projectile GO and two children GO: a PhysicsColliders GO and a HitBoxColliders GO.

The PhysicsCollidersGO job is to hold the colliders that define the solid regions of the projectile using Collider2D components. It's GO is on a Projectile layer which is set to collide with other solid layers such as the ones my walls are on. Walls are static colliders.

The HitBoxCollidersGO job is to define the a HitBox area. It's GO is on a HitBox layer and also uses Collider2D components that are set to be triggers. A HitScript on the GO listens for OnEnterTrigger.

Projectiles are set in motion by setting the velocity of the RigidBody once upon firing.

Here is a visual of the structure:

 ProjectileGO
- PhysicsCollidersGO
- HitBoxCollidersGO


Here are descriptions of the GameObjects and their components:

 ProjectileGO
- RigidBody2D Component (collisionDetectionMode is set to Continious)

PhysicsCollidersGO (Layer is set to Projectile)
- BoxCollider2D Component

HitBoxCollidersGO (Layer is set to HitBox)
- BoxCollider2D Component (IsTrigger is set)
- HitScript Component


Problem 1. Projectiles will sometimes not collide with walls/solid objects/etc...

Problem 2. Projectiles will sometimes not trigger a hit.

What could be causing these inconsistencies? How can ensure that collisions and triggers will consistently behave correctly?

If thats not an option, (or in conjunction with reducing the speed) you should look to changing the Collision Detection Mode on the Rigidbody/2d Component
• We have a few options but by default unity chooses to use a less resource intensive method called Discrete. You can chose which Rigidbody objects you would like to increase the collision "sensitivity on" and ramp that mode up to Continuous or Continuous Dynamic and read more about them here in the documentation I have set objects with high priority interactions, Players, Enemies,Projectiles to continuous with some success.