Is player facing to object
#1

Hi,

How to check is player facing to specife object?
Reply
#2

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
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)