Is player facing to object
#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


Messages In This Thread
Is player facing to object - by audriuxxx - 05.06.2014, 14:37
AW: Is player facing to object - by Nero_3D - 05.06.2014, 14:57

Forum Jump:


Users browsing this thread: 2 Guest(s)