21.12.2018, 03:42
So I want to set a player to facing to a object,but not change the angle of object.
Please,I am a math noob
Please,I am a math noob
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); } |