05.06.2014, 14:57
Calculate the angle between the two positions (player pos and object pos) and compare it with the facing angle of the player
Well that is that I just wrote, no clue if that works flawless but give it a try
Well that is that I just wrote, no clue if that works flawless but give it a try
pawn Код:
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;
}