Detecting if near the edge of an object ?

Is there a way to detect if Rigidbody is near the edge of an object. For instance a stadium
if its near the edge it will try to go to the center… something like that ?

You can add Colliders to the edge of the arena/stadium, then use a raycast to determine how far you are from the edge.

http://unity3d.com/support/documentation/ScriptReference/Physics.Raycast.html

or you could place said colliders on the edge of the arena itself, and then when the object enters it, tell it to go the other way, or to a certain position.

If the arena is circular, you could do it two ways that I can think of right off the bat:

  1. Make one big Sphere Collider, and use it in reverse: check to see if you are in it, if you Leave it, trigger.
    (this might not quite work, but throwing it out there for brainstorming reasons)

  2. You could have an object (an empty GameObject will do), and constantly measure the distance to that object.
    This should work fine, and has the benefit of being able to work at multiple ranges.