05.06.2014, 14:37
Hi,
How to check is player facing to specife object?
How to check is player facing to specife object?
IsPlayerFacingPos(playerid, Float: degrees, Float: X, Float: Y) {
new
Float: pX,
Float: pY,
Float: pZ
;
if(GetPlayerPos(playerid, pX, pY, pZ)) {
pX = -atan2(pX - X, pY - Y);
if(pX < 0.0) {
pX += 360.0;
}
GetPlayerFacingAngle(playerid, pY);
pX -= pY;
if(pX < -180) {
pX += 360.0;
}
else if(pX > 180.0) {
pX -= 360.0;
}
return (-degrees < pX < degrees);
}
return false;
}