Like mercc said, use scripting. Here’s the code, assuming that you have a ray sensor (detecting cube objects - objects with a ‘cube’ property, for example) and an Always sensor hooked up to a Python controller running the script:
cont = logic.getCurrentController() # The Python controller running this script
obj = cont.owner # The object running the script
ray = cont.sensors['Ray'] # The ray sensor checking for cubes
maxdist = 5 # In blender units, the maximum pick-up distance
if ray.positive:
cube = ray.hitObject
if obj.getDistanceTo(cube) < maxdist:
cube.setParent(obj)
That should work so that you can change the minimum distance to the cube that you can pick it up.