Check if player is behind mob in Lua - allfoxwy/UnitXP_SP3 GitHub Wiki
/script message(tostring(UnitXP("behind", UNIT_ID_0, UNIT_ID_1)));
UNIT_ID could be player, target... also GUID string "0x12345"
Return TRUE for Unit 0 is behind Unit 1, NIL for error.
Normally behind
is calculated on server. However UnitXP_SP3 is based on client data, which means it could result wrongly/delayed. The expectation is that when the mob is in a stable position attacking the tank, this method could give a reasonable prediction.
By default this method judge the front half π radians
cone as front, and the back half π radians
cone as back. However some mobs in the game have a strange hit box which is not like this.
So there is a threshold could be adjusted:
/script message(tostring(UnitXP("behindThreshold", "set", VALUE)))
VALUE is a float number by default is π / 2
(about 1.57079632679). When it is set greater than π / 2
, the half cone which is judged as back
would become smaller.