GetXYInFrontOfVehicle problem?
#1

GetVehiclePos(id, x, y, z);
GetXYInFrontOfVehicle(playerid, x, y, 1.4249);

ok if a vehicle is facing like > 350 && < 360 and > 0 && < 10 it works fine, but when a vehicle turns, or is facing left or right, the offset is bad?

pawn Код:
stock GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetVehiclePos(vehicleid, x, y, a);
    GetVehicleZAngle(vehicleid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
Reply
#2

This should be the right stock

pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance) // ******
{
    new Float:a;

    GetPlayerPos(playerid, x2, y2, a);
    GetPlayerFacingAngle(playerid, a);

    if(GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }

    x2 += (distance * floatsin(-a, degrees));
    y2 += (distance * floatcos(-a, degrees));
}
Reply
#3

... did i mention it WORKS? but when a vehicle is facing left or right it returns a bad x and y!
Reply
#4

solved using:
pawn Код:
stock GetXYBehindOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
    new Float: a;
    GetVehiclePos( vehicleid, x, y, a );
    GetVehicleZAngle( vehicleid, a );
    x += ( distance * floatsin( -a+180, degrees ));
    y += ( distance * floatcos( -a+180, degrees ));
}
with distance 3.

woops, wrong topic
Reply
#5

Quote:
Originally Posted by xir
Посмотреть сообщение
This should be the right stock

pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance) // ******
{
    new Float:a;

    GetPlayerPos(playerid, x2, y2, a);
    GetPlayerFacingAngle(playerid, a);

    if(GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }

    x2 += (distance * floatsin(-a, degrees));
    y2 += (distance * floatcos(-a, degrees));
}
its the same function lolz... just adding spaces and 1 check >_>
-.-"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)