I think you can just apply a vizproximity sensor with a circlearea of 5 (meters) to one (moving) avatar, and add a vizproximity target to the other (moving) avatar. When the avatars are within 5 meters from each other, the sensor (avatar1) should sense the target (avatar), and then you can respond to that event.
See the example below
Code:
import viz
import vizact
import vizshape
import vizproximity
viz.go()
sphere = vizshape.addSphere(radius=1)
sphere.setPosition(0,0,20)
sphere.color(viz.GREEN)
box = viz.add('box.wrl')
box.color(viz.ORANGE)
def moveObjects():
boxPos = box.getPosition()
boxPos[2] += .1
box.setPosition(boxPos)
spherePos = sphere.getPosition()
spherePos[2] += .01
sphere.setPosition(spherePos)
vizact.ontimer(.1, moveObjects)
manager = vizproximity.Manager()
target = vizproximity.Target(sphere)
manager.addTarget(target)
sensor = vizproximity.Sensor( vizproximity.CircleArea(5),source=box)
manager.addSensor(sensor)
def EnterProximity(e):
print 'enter'
def ExitProximity(e):
print 'exit'
manager.onEnter(sensor,EnterProximity)
manager.onExit(sensor,ExitProximity)