Set player facing to a object
#2

Quote:

stock SetPlayerFacingObject(playerid, object)
{
new Float:Px, Float:Py, Float: Pa;
new Float,Float:y,Float:z;
GetDynamicObjectPos(object, x, y, 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);
}

Here you go.
Reply


Messages In This Thread
Set player facing to a object - by 3417512908 - 21.12.2018, 03:42
Re: Set player facing to a object - by Tickle - 21.12.2018, 07:03

Forum Jump:


Users browsing this thread: 1 Guest(s)