[help] i can't fix this so it also works for negative values
#1

I was making a function to set the player's facing angle to a point(x and y) on the map
it's like SetCameraLookAt but for the player and only x and y coord.

this is what i already had:
pawn Код:
stock SetPlayerLookAt(playerid, Float:x, Float:y)
{
    new Float:Px, Float:Py, Float: Pa;
    GetPlayerPos(playerid, Px, Py, Pa);
    Pa = atan(floatdiv(floatsub(y, Py), floatsub(x, Px))); //pythagoras -> this is the code that doesn't work when i use negative floats

    new Float:Par = floatadd((floatsub(Pa, (floatmul(Pa, 2)))), 90); //calculating the angle in gta from the angle i got with pythagoras
(see [url]http://forum.sa-mp.com/index.php?topic=89950.0[/url]) this code works good

    SetPlayerFacingAngle(playerid, Par);

    new text[64];
    format(text, sizeof text, "real angle = %f | gta angle = %f", Pa, Par);
    SendClientMessage(playerid, 0xFF3399AA, text); //just debugging
}
it only works if the X and Y are positive but when they're negative it sets the wrong facingangle
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)