There is a distance function that takes the x, y value of the first object followed by the x, y value of the second and returns the distance. Use the system's compare two values event and type:
distance(<name of object 1>.X, <name of object 1>.Y, <name of object 2>.X, <name of object 2>.Y)
in the first value and the desired distance in the second.