As we know, UnitPosition and other position functions not work any more in dungeons and raids from patch 7.1.
Ref: http://us.battle.net/forums/en/wow/topic/20749494846
Anyone know a working solution to calculate distance between 2 players in raid/party group?
Old code - not work
PHP Code:
function ComputeDistance(unit1, unit2)
local y1, x1, _, instance1 = UnitPosition(unit1)
local y2, x2, _, instance2 = UnitPosition(unit2)
return instance1 == instance2 and ((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ 0.5
end