20.02.2013, 16:34
Hi i want to get the Rotation X for a object according the player angle, but i dont know how to do this calculation, its possible?
Angle= new Float:Angle;
GetPlayerFacingAngle(playerid, Angle);
X to point = -1412.1890
Y to point = 2351.3638
My calcul = -1412.1890 * acos(Angle) - 2351.3638 * asin(Angle)
Float:PointAngle(playerid, Float:xa, Float:ya, Float:xb, Float:yb)
{
new Float:carangle;
new Float:xc, Float:yc;
new Float:angle;
xc = floatabs(floatsub(xa,xb));
yc = floatabs(floatsub(ya,yb));
if (yc == 0.0 || xc == 0.0)
{
if(yc == 0 && xc > 0) angle = 0.0;
else if(yc == 0 && xc < 0) angle = 180.0;
else if(yc > 0 && xc == 0) angle = 90.0;
else if(yc < 0 && xc == 0) angle = 270.0;
else if(yc == 0 && xc == 0) angle = 0.0;
}
else
{
angle = atan(xc/yc);
if(xb > xa && yb <= ya) angle += 90.0;
else if(xb <= xa && yb < ya) angle = floatsub(90.0, angle);
else if(xb < xa && yb >= ya) angle -= 90.0;
else if(xb >= xa && yb > ya) angle = floatsub(270.0, angle);
}
GetVehicleZAngle(GetPlayerVehicleID(playerid), carangle);
return floatadd(angle, -carangle);
}