To get the distance on the XY planes first pick the object with the corresponding UID.
Pick object where object.UID=turretobject.turret.targetUID
then you can use the distance expression wherever you need to.
distance(turretobject.x,turretobject.Y,object.x,object.y)
This distance will remain the same though regardless of the objects Z-elevation as the objects XY position does not change.