# Checking collision between 2 triggers based on distance. Possible?

In short what I’m trying to achieve is 2 triggers placed on a single game object e.g. a long rectangle.

The 1st trigger is at the edge of the object and the 2nd trigger is roughly 3 times the distance in front of the 1st trigger as represented by the image below. With the orange rectangle representing the object, the green outline is the 1st trigger & the green box representing the 2nd trigger.

When an object say a sphere hits the 2nd trigger it will play sound of low pitch.

The closer the sphere gets to the orange rectangle the sound will be pitched higher, the variable of pitch changes based on distance of the sphere from the 1st trigger. When there sphere gets closer to the 2nd trigger and further away from the 1st trigger, the sound will begin to pitch lower until it reaches it point of origin and will stop when the sphere is no longer triggering the 2nd trigger.

So my question, is any of this physically possible to do?

To apply a changing variable based on the distance between 2 triggers.

There are different ways to solve this, but what I’d suggest is to use different game objects in the hierarchy to manage different collisions.

Otherwise, you can get the object position from OnTriggerEnter and check the distance to the actual game object distance.