Depends on the number of game objects you want to check for, if a not that many you could cycle through a list of each object and check the distance.
See Vector3.Distance
This is similar to expanding the collider but if you had 100 objects and the closest was 200 units away then it’d be faster checking which one’s closest than expanding the collider till it hits something.
You can use it to find the closest object and act as if triggered.
EDIT:
Sorry for the misunderstanding and for going out immediately after answering! That link appears to be either wrong or down.
EDIT 2:
OK got it. looks like a trailing full stop nearest-point-on-mesh
Hmmm looks complex might have to think about this.
EDIT 3:
OK how’s this, increase your collider, let’s say 1 unit (1 meter) per frame (store in float IncUnit) and check for collisions. That increase can be anything you like as long as none of your GameObects can slip in between the size you’re increasing.
When the collider is triggered set a bool to say HaveInitialCollison = true;
In Update if that bool is true call a function to do the following.
Store these values:
bool BackUp = true //if still colliding
int AmountToDivideBy 2; // Double this with each step
float AmountToMove = IncUnit / AmountToDivideBy; // to check how far to resize the collider.
If BackUp = True then reduce your collider by half it’s size and check if a collison is still happening.
If no longer colliding set BackUp to false but increase the collider by AmountToMove instead of reducing. Each time do this:
AmountToDivideBy = AmountToDivideBy * 2;
Keep doing this until these are met:
A: there is a collision still happening
B: are happy that the increments are so small you must be at the closest point.
C: there’s only I GameObject being collided with. You’ll need some logic to handle this past your maximum AmountToDivideBy.
At this point do whatever check you want from that other page.
It’s not ideal but It’ll vastly reduce the number of operations being performed on just increasing the collider a fraction from 0 to the first collision.
Basically just jumps forward rapidly then, when collision happens, halves the distance until you are happy that it’s close enough and the only collision happening.