Detecting which collider is being hit when an object has multiple colliders.

My main character has a camera following behind him. I have been messing around with collision detection on the camera and have gotten the camera to zoom in when it collides with an object and zoom out when it isn't colliding. My problem is that when my camera zooms in and stops colliding it will try to zoom out and it gets really shaky because it wants to zoom in then out. My solution was to make two colliders around my camera so that if the larger one is the only one being hit then it wont zoom out so that I can get rid of this glitch. Problem is I don't know how to detect when only one of my two colliders is being hit so I can't use this. Does anyone know how to detect a specific collider is being hit or a suggestion on how to solve this problem will be nice too?

you can use GetComponents and get all components of a type. then you can iterate the array and check the names of your colliders. do smething like this

Collider c[] = GetComponents<Collider>();
foreach (Collider d in c)
if ( = "big collider") //dosomething
print ("big one");

js code

var colliders : Collider[];
c=GetComponents (Collider);
for (var d : Collider in c)
if ( == "big") //do something

also in OnTriggerEnter you can do this because it will pass you a collider named other.

if ( = "big collider") //do something

just give good names to your colliders. :)

Well what you could do is put another object as a child of the camera with a collider on it, and then detect which object was in collision rather than using multiple colliders on the camera.

Other than that it might be possible (I don't have access to Unity right now so I can't check) to put in two variables of type collider and just drag your colliders in there so that you could explicitly reference them.