SetObjectFacingPlayer (seen it before, removed?)
#4

pawn Код:
stock SetObjectFacePlayer(Float:Px, Float:Py, Float:x, Float:y)
{
    new Float: Pa;
    Pa = floatabs(atan((y-Py)/(x-Px)));
    if(x <= Px && y >= Py) Pa = floatsub(180, Pa);
    else if(x < Px && y < Py) Pa = floatadd(Pa, 180);
    else if(x >= Px && y <= Py) Pa = floatsub(360.0, Pa);
    Pa = floatsub(Pa, 90.0);
    if(Pa >= 360.0) Pa = floatsub(Pa, 360.0);
    return floatround(Pa);
}
This is a custom function I made for my own server, let me explain how to use it:

pawn Код:
CreateObject(model, x, y, z, rx, ry, SetObjectFacePlayer(objectx, objecty, playerx, playery)+offset_if_you_need_one);
Doesn't affect rx or ry though. I'd like to have that.
Reply


Messages In This Thread
SetObjectFacingPlayer (seen it before, removed?) - by Smurf[SMURF] - 18.09.2011, 00:50
Re: SetObjectFacingPlayer (seen it before, removed?) - by Backwardsman97 - 18.09.2011, 01:03
Re: SetObjectFacingPlayer (seen it before, removed?) - by Smurf[SMURF] - 18.09.2011, 01:33
Re: SetObjectFacingPlayer (seen it before, removed?) - by MP2 - 18.09.2011, 01:55

Forum Jump:


Users browsing this thread: 1 Guest(s)