Wrapping while warning in case of imminent collision after wrap

The question is: How can I get my game objects to "sense" if there's another object on the other side of the screen? So it knows if there's going to be an imminent collision even before wrapping over to the other side.

I thought it would be best to clarify the problem by making some illustrations so prepare for some daunting art work.

The illustration above shows some game objects floating about in 2D space. The edges of the screen is represented by the black frame. The dotted frame represents where the objects actually wrap. Every object has its own area which should detect the presence of other game objects (represented by the red circle in case you were left wondering).

The puzzle I'm left facing is illustrated below. As you can see there's an object about to wrap on the right side of the screen. Somehow the object needs to "sense" that there's also an other game object on the left side with which it's about to collide and send out a warning signal.

alt text

So if anybody has any suggestions on how to face the problem I'm all ears. (Preferably in c# =D) NOTE: I've only recently picked up Unity and C# so the more you're able to explain the better.


It seems like Physics.OverlapSphere would work well for that. If the object is near the border, use the object's transform.position and add/subtract the width of the playfield to get a new position, then check whether OverlapSphere returns anything at that new position.