SetPlayerFacingPlayer
#1

Does anyone know how you would get another players (thats close to you`s) relative position in Z angle to you. Then Turn your players Z angle the right amount to face the player you want.

I want this for my wave command and other animation commands, so the player directly waves at the player being waved at.

Thanks for you help in advance!
Reply
#2

Use a loop?
Reply
#3

Set thier rotation to opposites
Reply
#4

i think i got it:
i found an old set player facing an x y pos, and made it into setplayerfacingplayer:

pawn Code:
stock SetPlayerFacingPlayer(playerid, facingid)
{
    new Float:Px, Float:Py, Float: Pa;
    new Float:x,Float:y,Float:z;
    GetPlayerPos(facingid,x,y,z);
    #pragma unused z
    GetPlayerPos(playerid, Px, Py, 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 SetPlayerFacingAngle(playerid, Pa);
}
it should work.... i think
Reply
#5

Did you wan't to set () players to your specific facing angle?
Reply
#6

i don't understand what you meant but, what i want to do is lets say player id 5 wales up and waves at id 9, but is facing the other way, it will look stupid for him to wave at air, so it sets the waiving player directly looking at id 9. do you understand?

and i think that stock will work... i just gotta go in my server and test it out.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)